Posted By:
Robert_Lybarger
Posted On:
Thursday, September 7, 2006 10:56 PM
If you take the 'custom ant task' suggestion -- and why not -- I'd actually recommend a custom "condition" just based on the wording of your question. That's also covered in the ant manual to a degree, but I'll try to save some effort, since the manual's tutorial pages just are not well written. Of course, this is going to be *highly* compressed and might not be much better. ;-)
Your java class for the custom condition will implement the org.apache.tools.ant.condition.Condition class and will implement the eval() method:
public boolean eval() {
Project p = this.getProject();
String numStr = p.getProperty("deploy.clientno");
Integer I=null;
try {
I = new Integer(numStr);
} catch (NumberFormatExcepton nfe) {
return false;
}
int i = I.intValue();
return (i>=1000 && i<=9999);
}
At that point, register your custom condition using the "typedef" task. (see ant manual.) Then load the properties file using the "property" task using the "file" attribute option. (again, see ant manual.) Finally, look the "fail" and "condition" ant tasks and note you'll need to use a "not" condition to invert the result of your custom condition:
...
...
Hope that helps??
You could make it fancier by having attributes in the "is_four_digits" element which are set in the build.xml file instead of being hard-coded in the java source code. See the custom task tutorials if that sounds like a good idea.