Wednesday, December 25, 2013

[Java] Compilation ANT Script

This is an example of ANT script that compiles Java source code.

<?xml version="1.0" encoding="UTF-8"?>

<project default="compile" name="Example Compiler Script">

<!-- Default target -->
<target name="compile" depends="create.BinFolders,delete.GeneratedClasses,compile.project" />
<!-- Properties -->
<property name="checkout.project.dir" value="C:/Jenkins/.jenkins/jobs"/>
<!-- Create bin folders -->
<target name="create.BinFolders">
<echo>[START] :Creating bin folders</echo>
<mkdir dir="${checkout.project.dir}/workspace/bin"/>
<echo>[END] :Created bin folders</echo>
</target>

<!-- Delete classes -->
<target name="delete.GeneratedClasses">
<echo>[START] :Deleting generated classes</echo>
<delete>
<fileset dir="${checkout.project.dir}/workspace/javaproject/bin" includes="**/*.class"/>
</delete>
<echo>[END] :Deleted all generated classes</echo>
</target>

<!-- Compiling javaproject project -->
<target name="compile.project" description="target :compile.project">
<echo>[START] :Compiling javaproject project</echo>
<javac srcdir="${checkout.project.dir}/workspace/javaproject/src" destdir="${checkout.project.dir}/workspace/javaproject/bin">
<classpath>
<fileset dir="C:/Server/SupportJars" includes="**/*.jar"/>
</classpath>
</javac>
<echo>[END] :Finished compiling javaproject project</echo>
</target>

</project>

No comments:

Post a Comment