Ant var and property area

I have a main build script that calls up various targets. One of these goals must retain meaning, and the other goal must reflect it. Obviously this does not work, so I think it might be related to the area. I tried var, a property, and declared a property outside of target1. Since var seems to be changed, it looks like I need to use it instead, but every time my output is empty.

Main script

<antcall target="target1"/> <antcall target="display"/> 

In target1:

 <var name="myVar" value="${anotherVar}"/> 

On the display:

 <echo>${myVar}</echo> 
+7
ant
source share
5 answers

antcall will run the ant target in the new project and will not affect the main project in any way. Try running runtarget from antcontrib to run targets in one project.

+4
source share

Do you really need to use <antcall>? Can you use target dependencies instead?

As you suspect, using <antcall> essentially creates a new area.

+4
source share

You can trigger multiple targets with a single antcall element. Then these objects will share one instance of the project, including certain properties. To do this, specify the goals as nested elements, for example:

 <antcall> <target name="target1"/> <target name="display"/> </antcall> 
+2
source share

Another option I found is antcallback, and it seems to work. This limits what returns only to a specific list of values, which seems safer than opening an area of ​​the entire target (since it sets, creates, modifies many variables and properties).

 <antcallback target="target1" return="myVar"/> <antcall target="display"/> 

I think that all of them are feasible solutions, it depends only on what level you want to change the scope of the variable.

+2
source share
 <antcall target="display"> <param name="param1" value="anything" /> </antcall> 

put the above code in your target1. I am sure that now you can access your parameter.

0
source share

All Articles