You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by jh...@apache.org on 2007/03/02 12:32:03 UTC
svn commit: r513710 - in /ant/core/trunk/src:
main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
tests/antunit/taskdefs/condition/antversion-test.xml
Author: jhm
Date: Fri Mar 2 03:31:53 2007
New Revision: 513710
URL: http://svn.apache.org/viewvc?view=rev&rev=513710
Log:
<antversion>-TASK evaluates now atLeast and exactly attributes.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java?view=diff&rev=513710&r1=513709&r2=513710
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/AntVersion.java Fri Mar 2 03:31:53 2007
@@ -41,7 +41,15 @@
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());
+ }
}
/**
Modified: ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml?view=diff&rev=513710&r1=513709&r2=513710
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/condition/antversion-test.xml Fri Mar 2 03:31:53 2007
@@ -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>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org