I am modifying my exiting ant script to support differential builds. For that I have used modified selector in fileset for finding only modified files. But the problem is when I am doing full build I need to bypass modified filter based on some property or param. As shown below. Is there anyway to do that.
<project name="test" default="dt" basedir=".">
<target name="dt1">
<copy todir="ant_temp2">
<fileset dir="ant_temp1">
<if>
<equals arg1="${ABC}" arg2="true" />
<then>
<modified update="true" />
</then>
</if>
<exclude name="*.txt"/>
</fileset>
</copy>
</target>
<target name="dt">
<antcall target="dt1">
<param name="ABC" value="true" />
</antcall>
</target>
<target name="dt2">
<antcall target="dt1" />
</target>
</project>
If I invoke the above ant script using dt
target then I need to consider modified
and the exclude
in fileset
task. If it is invoke using dt2
then I need to consider only exclude
in the fileset
task.
I am not able to use the above script beacuse fileset
does not support nested if
task. That's why I am looking for alternative way to do this. Please suggest some ways to do this.
P.S: I don't want to create the two targets with the same copy task one with including modified
and exclude
in fileset
and another target with only exclude
.
I have used below ant script to achieve my requirements.
<project name="test" default="dt" basedir=".">
<patternset id="fs1">
<exclude name="*.txt"/>
</patternset >
<target name="dt1">
<copy todir="ant_temp2">
<fileset dir="ant_temp1">
<patternset refid="fs1" />
</fileset>
</copy>
</target>
<target name="dt3">
<copy todir="ant_temp2">
<fileset dir="ant_temp1">
<modified update="true" />
<patternset refid="fs1" />
</fileset>
</copy>
</target>
</project>
I have created reusable pattern set and developers will update their exclusions in that pattern set and i am reusing that pattern sets for normal and incremental builds.