I'm trying to get Ant to compile only parts of my project depending on a property (module
) I set in the properties file. This is my first "real" interaction with ant so please bear with me :).
I don't want to create multiple targets because the only thing that differs between modules in the build process is the number of classes that are being compiled and some resources.
Now, here's my compile target:
<target name="compile.classes" depends="init" description="compile the source">
<mkdir dir="${classes}"/>
<mkdir dir="${lib}"/>
<copy todir="${classes}">
<fileset dir="${src}">
<patternset refid="resources"/>
</fileset>
</copy>
<echo message="${classes}"/>
<!-- Compile the java code from ${src} into ${classes} -->
<javac srcdir="${src}" destdir="${classes}">
<!-- Conditions for compiling the separate modules -->
<classpath refid="libs"/>
</javac>
</target>
What I want to have are some conditionals based on the value of the module
property I've already set. Something like:
<javac srcdir="${src}" destdir="${classes}">
<if>
<equals arg1="${module}" arg2="gpl" />
<then>
<patternset refid="gpl-classes"/>
</then>
<elseif /> <!-- etc -->
</if>
</javac>
Although I've installed ant-contrib fine (I've tested the if tag somewhere else with a simple echo and it worked) it doesn't let me place if conditionals inside javac
tags. Also, it doesn't let me place them inside patternset
tags.
Is there any way I can condition what classes I compile depending on a property?