I have multiple projects. Each of the project may or may not have a dependent classes. If I have dependent classes I have to build a jar based on the java files in the class property and add to project1 jar if the property is specified or it should be ignored. Now I have to dynamically loop through all of the projects and in the target i have to test for the existance of the property and build if the property exist.
<target name="test">
<foreach list="${projects}" target="test2" param="project"/>
</target>
<target name="test2">
<!-- Here i have to test wheter ${project}.class exist or not-->
</target>
The following is a sample property file
projects=project1,project2,...
project1.class=class1.java,class2.java
Here project2 doesn't have a .class property,So it should not build a dependency jar. How can I test the existance of the property . I know is set can be used to know the status of property but this comes dynamically can someone help on this ?
You are on the right track with <isset>
:
<target name="test2">
<if>
<isset property="${project}.class"/>
<then>
<echo message="${project}.class exists -- let's run a build"/>
</then>
</if>
</target>