Check out this code fragment:

<target name="nowork" description="this one does not work when
property is not set">
   <echo message="property2 is ${property2}"
if="${property::exists('property2')}" />
</target>

The echo statement shouldn't happen if property2 doesn't exist;
however, the following error happens:

Property evaluation failed.
Expression: property2 is ${property2}
                           ^^^^^^^^^
    Property 'property2' has not been set.

Should this be reported as a bug somewhere?

I've attached a short build file which demonstrates the issue.
<?xml version="1.0"?>
<project name="TestProperties" default="run">
    <property name="property1" value="something"/>
    <!--property name="property2" value="something else"/-->

    <target name="work" description="this one works, property is set">
        <echo message="property1 is ${property1}" 
if="${property::exists('property1')}" />
    </target>

    <target name="nowork" description="this one does not work when property is 
not set">
        <echo message="property2 is ${property2}" 
if="${property::exists('property2')}" />
    </target>
    
    <target name="run" depends="work, nowork">
        <echo message="Target: run" />
    </target>
</project>

Reply via email to