Reputation: 1050
I have a requirement where in a build.xml file I have two variables.
While calling the build.xml file from Java program, I will pass the values as properties And while calling the same build.xml file from command line, it should ask the user for input
Now I have to check whether a particular property is having any value or not, if not, then ask user to input the value
Can you please help me to write this build.xml file?
Thanks in advance.
Upvotes: 0
Views: 1726
Reputation: 28706
You can do it like this:
<target name="printMyProperty" depends="askUser">
<echo message="${my.property}"/>
</target>
<target name="askUser" unless="my.property">
<input
message="Enter the value for my.property:"
addproperty="my.property"
/>
</target>
The unless
attribute is the solution to your problem. It means "execute this target only if my.property is not set".
Upvotes: 3