How to change the value of variable in called target in ant - ant

can i change the value of parameter in called target and then retrieve it in the calling target in ant.Probably By refid if there is any other way that is appreciated.

Normally you cannot modify an ant property in ant once it's set, but as oers pointed out in a comment, you can use the Variable task in ant-contrib. You can even override an existing property with a Variable. According to the documentation, you should still use properties in most cases, and only use variables in the cases where you really need to be able to modify a value.
Another workaround is to set additional properties and call the other targets using those properties.

Related

UE5 - BuildTool: How can I set Target.WindowsPlatform.bUpdatedCPPMacro property?

I'm trying to use a third party library inside ue5. For it to compile, I need to add the "Zc__cplusplus" option to the compiler.
While going through a file named "VCToolChain.cs" I found out that, the needed option will be included if the variable "Target.WindowsPlatform.bUpdatedCPPMacro" is set to true.
So my question is where and when is this variable set?
Can I set it in some non hacky way?

Setting a new Environment Variable from Custom Activity in a Workflow

Is there a way to either create a new Environment Variable from within a WF 4.0 workflow or update an existing one if it already exists?
You can set a enviroment variable inside an code activity.
You can use the System.Activities.Statements.InvokeMethod activity to call the System.Environment.SetEnvironmentVariable static method.
In the Parameters setting, you'll need to pass 2 'In' parameters. The first will be the name of your environment variable, the 2nd will be the value.

Groovy hasProperty shortcut

I am iterating over a list of objects of mixed types. For each object I access a bunch of properties. Some of these objects will not have some of the properties. Is there a way to avoid using object.hasProperty method to safely access nonexisting properties?
You could iterate through the object's properties.
The following link might help for this :-
Groovy property iteration
looks like the only reasonable way is to use hasProperty method for sanity check

passing parameters to dependent ant target

i have two ant files
mainBuild.xml
subBuild.xml
subBuild.xml is imported in the mainBuild.xml. One of target from mainBuild depends on subBuild. I need to pass the argument to the dependent ant target. I dont want to use the <antcall> or the <ant> tags, as i need the some properties from the
You can define the arguments in the property files, and then read that property in ant like this.
<property file="build.start.properties"/>
All properties in the property file will be imported in ant, and will be available as ant properties, which you can use in both mainBuild.xml and subBuild.xml.
refer this for further reference
Macros are one way to have re-usable code in ant. You can call them with different argument. Re-using of targets (using property ) may not be desirable as the properties are immutable.

Ant property not evaluated correctly?

I am using a custom ant buildscript for my Android app.
I have a property ${distributionTarget} that is evaluated to for example Android_Market.
However, in some methods, I don't get the output of app-Android_Market-release.apk but I get app-${distributionTarget}-release.apk.
I am positive the property has been set correctly, since earlier in the build-stage I have a echo method, that does shows the value of the property correctly.
What am I missing here?
It appears the property was initialized earlier on with no value. Refactoring the build-script to init the properties later made it work.

Resources