Create an ant file to run other ant files
Solution 1
Maybe have a target like below in encompassing ant file:
<target name="all">
<ant antfile="antFile1" target="clean" />
<ant antfile="antFile2" target="create" />
...
</target>
Refer here: http://ant.apache.org/manual/Tasks/ant.html
Solution 2
You can also have import tags:
<import file="my_ant_file.xml">
And then you can call the ant targets in that file. You may want to qualify (add a prefix to) your target names to avoid ambiguity if you do that.
EDIT: Calling the ant targets from the imported file is exactly the same as calling local targets:
<antcall target="my_local_target">
<antcall target="my_target_from_an_imported_file">
You can also use them as dependencies:
<target name="my_target" depends="my_target_from_an_imported_file">
Think of it the same way as importing in any programming language. Once it's imported you can use it as-if it were just another target in your file.
Here is the import documentation.
TookTheRook
"We learn more by looking for the answer to a question and not finding it than we do from learning the answer itself." ~Lloyd Alexander
Updated on February 11, 2020Comments
-
TookTheRook about 4 years
I saw this relevant question but my situation is different so asking this again. Basically, I have 12 ant files that I have to run in a specific sequence. For each ant file, I select a different target, such as "create" or "build and deploy all." How can I create an ant file that will call of the right targets for all of these files?
Pseudocode: <Call antFile1, "clean"> <Call antFile1, "create"> <Call antFile2, "build"> . . . <Call antfile12, "build and deploy all">
-
TookTheRook almost 13 yearsOnce I have imported all the files, how can I call their targets? Could you give me an example of the syntax?
-
TookTheRook almost 13 yearsWell the problem is that when I call other ant files form a certain folder, instead of following their own properties files, the ant files cannot find the path variables since the master_ant_file (the one that I am creating) does not store the path variables (since each ant build has different path variables). If I put in the path variables of the first ant I call in the properties file of the maser_ant_file, the first build executes fine but the second one cannot find its paths. Is there a way to fix this?
-
Gyan aka Gary Buyn almost 13 yearsSorry I'm not sure I can answer that one. You might want to ask a second question about that, I'm sure someone else here can help you with it.
-
Manticore almost 6 yearsRemember to set inheritAll to false, if you want a basedir that is relative to your build.xml-parent-folder !