I have all my building tasks split into several targets which are not intended to be executed separately. I'm trying to use user inputted value from targetA
in two other targets but they seem to be in a diffrent scope. One way of fixing that is to add targetA
to the depends
property of targetB
and targetC
but it results in targetA
being called twice.
So is there any way to save that value globally? Or maybe ensure that target gets executed only once?
<target name="targetA" description="..." hidden="true">
<input propertyName="property" defaultValue="default" ></input>
<!-- some action goes on here -->
</target>
<target name="targetB" description="..." hidden="true">
<echo message="${property}" />
<!-- some action goes on here -->
</target>
<target name="targetC" description="..." hidden="true">
<echo message="${property}" />
<!-- some action goes on here -->
</target>
<target name="install">
<phingcall target="targetA" />
<phingcall target="targetB" />
<phingcall target="targetC" />
</target>
Well, found the solution.
Property scopes seem to be nested one into another, so we can describe input
target, put all our inputs there and then define main target install
as depending on input
. Now we will have all of our properties available for all the targets invoked from install
like that:
<target name="input" description="..." hidden="true">
<input propertyName="property" defaultValue="default" ></input>
<!-- more inputs here -->
</target>
<target name="targetB" description="..." hidden="true">
<echo message="${property}" />
<!-- some action goes on here -->
</target>
<target name="targetC" description="..." hidden="true">
<echo message="${property}" />
<!-- some action goes on here -->
</target>
<target name="install" depends="input">
<phingcall target="targetB" />
<phingcall target="targetC" />
</target>