0

Possible Duplicate:
Intermodule dependency in ant

I have three java projects as below

Report, Core, Apps.

in which Core is dependent on Report ,so first report should be converted to jar and embeedded into core then Core need to be converted into jar and both core and report needs to be embedded into Apps and Apps should be converted to executable jar.

How to write ANT script for the above thing?

Thanks

Community
  • 1
  • 1
user1321824
  • 445
  • 3
  • 22
  • 41

1 Answers1

0

As apps target is depending upon the core, and core depends upon reports and all three of them creates jar... So we can use antcall target for this... You can define path element, and createjar target...

Create a common path entry...

<path id="master-classpath">
    <fileset dir="${lib/dir}">
        <include name="*.jar"/>
    </fileset>
    <pathelement path="${build.dir}"/>
</path> 

<target name="createJar" description="creating the jar">
    <javac destdir="${build.dir}" ncludeantruntime="false">
        <src path="${src.dir}"/>
     <classpath refid="${var-classpath}"/>
    </javac>
    <WRITE CODE FOR JAR CREATION>
    <copy the jar to lib/dir>
</target>

<target name="report">
 <antcall target="createJar">
     <param name="src.dir" value="./src/reports"/>
    <param name="var-classpath" value="master-classpath"/>
        <param name="jar-name" value="reports.jar"/>
  </antcall>
</target>

<target name="core" depends="report">
 <antcall target="createJar">
     <param name="src.dir" value="./src/core"/>
        <param name="jar-name" value="core.jar"/>
  </antcall>
</target>

<target name="apps" depends="core">
 <antcall target="createJar">
     <param name="src.dir" value="./src/core"/>
        <param name="jar-name" value="core.jar"/>
  </antcall>
</target>

Something like this will help you to create your file. This code is not complete. You need to make lot of changes to make it work...

Vishal
  • 3,189
  • 1
  • 15
  • 18