|
@@ -20,25 +20,38 @@ package org.apache.tools.ant.taskdefs.condition; |
|
|
|
|
|
|
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.BuildException; |
|
|
import org.apache.tools.ant.Project; |
|
|
import org.apache.tools.ant.Project; |
|
|
|
|
|
import org.apache.tools.ant.Task; |
|
|
import org.apache.tools.ant.util.DeweyDecimal; |
|
|
import org.apache.tools.ant.util.DeweyDecimal; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* An Ant version condition. |
|
|
* An Ant version condition. |
|
|
* @since Ant 1.7 |
|
|
* @since Ant 1.7 |
|
|
*/ |
|
|
*/ |
|
|
public class AntVersion implements Condition { |
|
|
|
|
|
|
|
|
public class AntVersion extends Task implements Condition { |
|
|
|
|
|
|
|
|
private String atLeast = null; |
|
|
private String atLeast = null; |
|
|
private String exactly = null; |
|
|
private String exactly = null; |
|
|
|
|
|
private String propertyname = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Evalute the condition. |
|
|
* Evalute the condition. |
|
|
* @return true if the condition is true. |
|
|
* @return true if the condition is true. |
|
|
* @throws BuildException if an error occurs. |
|
|
* @throws BuildException if an error occurs. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
public void execute() throws BuildException { |
|
|
|
|
|
if (propertyname == null) { |
|
|
|
|
|
throw new BuildException("'property' must be set."); |
|
|
|
|
|
} |
|
|
|
|
|
getProject().setNewProperty(propertyname, getVersion().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public boolean eval() throws BuildException { |
|
|
public boolean eval() throws BuildException { |
|
|
validate(); |
|
|
validate(); |
|
|
DeweyDecimal actual = getVersion(); |
|
|
DeweyDecimal actual = getVersion(); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("AntVersion::actual = " + actual); |
|
|
|
|
|
|
|
|
if (null != atLeast) { |
|
|
if (null != atLeast) { |
|
|
return actual.isGreaterThanOrEqual(new DeweyDecimal(atLeast)); |
|
|
return actual.isGreaterThanOrEqual(new DeweyDecimal(atLeast)); |
|
|
} |
|
|
} |
|
@@ -123,4 +136,13 @@ public class AntVersion implements Condition { |
|
|
public void setExactly(String exactly) { |
|
|
public void setExactly(String exactly) { |
|
|
this.exactly = exactly; |
|
|
this.exactly = exactly; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getProperty() { |
|
|
|
|
|
return propertyname; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setProperty(String propertyname) { |
|
|
|
|
|
this.propertyname = propertyname; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |