I have a doubt, I made this build file in order to build 3 different projects
<?xml version="1.0" encoding="UTF-8"?>
<project name="Trinity" basedir="." default="buildall">
<target name="project1">
<ant dir="C:/work/project1"/>
</target>
<target name="project2" depends="project1">
<ant dir="C:/work/project2"/>
</target>
<target name="project3" depends="project1, project2">
<ant dir="C:/work/project3"/>
</target>
<target name="buildall" depends="project3"/>
</project>
This is working now. But I wan to also clean the project before doing the build.
In fact I want to acomplish this: C:/work/project1 ant clean build C:/work/project2 ant clean build C:/work/project3 ant clean build
Thanks in advance.
update: Thanks to the quick response from Alex I did a new build.xml file with the following. And I believe is working well, what do you think?.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Trinity" basedir="." default="buildall">
<target name="project1">
<ant dir="C:/work/project1" target="clean"/>
<ant dir="C:/work/project1" target="build"/>
</target>
<target name="project2" depends="project1">
<ant dir="C:/work/project2" target="clean"/>
<ant dir="C:/work/project2" target="build"/>
</target>
<target name="project3" depends="project1, project2">
<ant dir="C:/work/project3" target="clean"/>
<ant dir="C:/work/project3" target="build"/>
</target>
<target name="buildall" depends="project3"/>
</project>
Thanks.
According to the ant task, you can specify the targets of the external ant build files
<ant dir="C:/work/project1" target="clean build">
Edit:
According to the ant documentation:
You can specify multiple targets using nested elements instead of using the target attribute. These will be executed as if Ant had been invoked with a single target whose dependencies are the targets so specified, in the order specified.
So you can list out multiple targets this way:
<ant dir="C:/work/project1">
<target name="clean" />
<target name="build" />
</ant>
Alternatively you can define a new target in the Project1,2,3 build.xml files called cleanBuild
which will in turn call clean
followed by build
if you want to keep it as a single xml element <ant dir="C:/work/project1" target="cleanBuild">