ANT (Example) - 2
18 May 2008Do read the first part of this post. I will continue with the ANT build example.
After defining the init target, Ill define a compile target as follows:
<target name="compile" depends="init"> <javac srcdir="${srcDir}" destdir="${buildDir}"/> </target>
It depends on init, so if you run this one, init will be executed first. Compile target compiles the code in the source directors and generates the class files in the build directory.
Time to define the third target which will generate the JAR file in the distribution directors. It is named dist and it depends on compile.
<target name="dist" depends="compile"> <jar destfile="${distDir}/package-${DSTAMP}.jar" basedir="${buildDir}"> <manifest> <attribute name="Built-By" value="${user.name}"/> <attribute name="Main-Class" value="package.Main"/> </manifest> </jar> <jar destfile="${distDir}/package-src-${DSTAMP}.jar" basedir="${srcDir}"/> </target>
We are generating 2 JARs – one with source code and the other without source code.
At the end, simply I will define a clean target to remove the unwanted directories.
<target name="clean"> <delete dir="${buildDir}"/> <delete dir="${distDir}"/> </target> </project>
Hope this helps.
Related Posts:
- No related posts
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: ANT (Example) - 2