I have two ant files:
1) Main file
<include file="otherFile.xml" as="otherFile"/> <target name="firstTarget"> <antcall target="otherFile.secondTarget"/> </target>
2) Utilities file
<target name="secondTarget">
<antcall target="thirdTarget"/>
</target>
<target name="thirdTarget">
<echo message="ok"/>
</target>
When I invoke the firstTarget
it says it cannot find the thirdTarget
.
If I change the secondTarget
this way:
<target name="secondTarget"> <antcall target="otherFile.thirdTarget"/> </target>
then it works. But then I cannot use secondTarget directly. Because the second file does not knwon the prefix otherFile
When a target is invoked by antcall , all of its dependent targets will also be called within the context of any new parameters. For example. if the target doSomethingElse ; depended on the target init , then the antcall of doSomethingElse will call init during the call.
Ant tasks are the units of your Ant build script that actually execute the build operations for your project. Ant tasks are usually embedded inside Ant targets. Thus, when you tell Ant to run a specific target it runs all Ant tasks nested inside that target.
You may try:
<ant antfile="otherFile.xml" target="secondTarget"/>
And no need to include the otherFile.
Use the following pattern in any file that will be both directly invoked and included:
<project name="my-project">
<!-- if this is the top-level build.xml, ${self} == "" -->
<condition property="self" value="">
<equals arg1="${ant.project.name}" arg2="my-project" />
</condition>
<!-- if this is an included build.xml, ${self} == "my-project." -->
<property name="self" value="my-project." /><!-- note the trailing dot -->
...
Then use the following for the antcall:
<antcall target="${self}target" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With