Browse Source

<antversion>-TASK evaluates now atLeast and exactly attributes.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@513710 13f79535-47bb-0310-9956-ffa450edef68
master
Jan Materne 18 years ago
parent
commit
71220c5b2f
2 changed files with 29 additions and 2 deletions
  1. +9
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
  2. +20
    -1
      src/tests/antunit/taskdefs/condition/antversion-test.xml

+ 9
- 1
src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java View File

@@ -41,7 +41,15 @@ public class AntVersion extends Task implements Condition {
if (propertyname == null) {
throw new BuildException("'property' must be set.");
}
getProject().setNewProperty(propertyname, getVersion().toString());
if (atLeast!=null || exactly!=null) {
// If condition values are set, evaluate the condition
if (eval()) {
getProject().setNewProperty(propertyname, getVersion().toString());
}
} else {
// Raw task
getProject().setNewProperty(propertyname, getVersion().toString());
}
}

/**


+ 20
- 1
src/tests/antunit/taskdefs/condition/antversion-test.xml View File

@@ -23,8 +23,27 @@
<target name="test-task">
<antversion property="antversion"/>
<au:assertPropertyEquals name="antversion" value="1.7.1"/>
<au:assertPropertySet name="antversion" message="Property 'antversion' should be set."/>
<echo>AntVersion=${antversion}</echo>
</target>
<target name="test-property-conditional1">
<antversion property="antversion" atleast="2.0.0"/>
<au:assertTrue message="Property 'antversion' should not be set because this is not Ant 2.0.0+.">
<not>
<isset property="antversion"/>
</not>
</au:assertTrue>
</target>
<target name="test-property-conditional2">
<antversion property="antversion" atleast="1.7.0"/>
<au:assertTrue message="Property 'antversion' should be set because we should have Ant 1.7.0+ (${ant.version}).">
<isset property="antversion"/>
</au:assertTrue>
</target>
<target name="all">
<au:antunit>


Loading…
Cancel
Save