ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 46147] New: condition or fails with more than two tests
Date Tue, 04 Nov 2008 23:28:08 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=46147

           Summary: condition or fails with more than two tests
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: lists@pbw.id.au


When <condition><or>...</or></condition> contains more than two tests,
the
condition is set when all tests individually return false.

This was exposed when installing Metro 1.4.

<project name="test" default="x" basedir=".">

    <!-- Check if we are running JAVA SE 6 update release 3 or older -->
    <condition property="jdk6">
        <or>
            <contains string="${java.version}" substring="1.6.0_1"/>
            <contains string="${java.version}" substring="1.6.0_2"/>
            <contains string="${java.version}" substring="1.6.0_03"/>
        </or>
    </condition>

    <target name="jdk6-message" if="jdk6">
        <echo message="NOTE: Metro is being installed using JDK6."/>
        <echo/>
    </target>

  <target name="x" depends="jdk6-message">
      <echo>java.version = ${java.version}</echo>
      <echo>ant.version = ${ant.version}</echo>
  </target>

</project>

The above file output is:

Buildfile: build.xml

jdk6-message:
     [echo] NOTE: Metro is being installed using JDK6.
     [echo]

x:
     [echo] java.version = 1.6.0_10
     [echo] ant.version = Apache Ant version 1.7.1 compiled on June 27 2008

BUILD SUCCESSFUL
Total time: 0 seconds

That is, the condition jdk6 is true. Note that the java.version is 1.6.0_10.

If the condition is changed by removing out one of the three active "contains"
tests, the result is:


Buildfile: build.xml

jdk6-message:

x:
     [echo] java.version = 1.6.0_10
     [echo] ant.version = Apache Ant version 1.7.1 compiled on June 27 2008

BUILD SUCCESSFUL
Total time: 0 seconds

The condition also seems to be sensitive to the presence of comments within the
<or/>.


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message