ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Generalization of available (setif and setunless)
Date Fri, 24 Mar 2000 08:39:31 GMT
Hi,

I'm subscribed to this group a very short time. As I don't know if
these things have been discussed before I won't submit code right
know - maybe somebody else has already done something similar (which
would have happened to my own version of a JUnit task).

What I'm thinking about is a more general form of the Available task,
something like

<setif property="NAME" value="VALUE" conditiontester="CLASSNAME"
        condition="CONDITION" />

Where conditiontester would implement something like 

interface ConditionTester {
    public void setCondition(String condition);
    public boolean testCondition() throws BuildException;
}

This would set the property named NAME to VALUE if CONDITION has been
evaluated to true (false in the case of setunless) by an instance of
CLASSNAME.

Furthermore setif/unless should allow for some built-in conditions (for a
proposal how to add new built-ins without changing too much code see my 
other mail):

* fileavailable, resourceavailable and classavailable 

  can quite easily be implemented by minor modifications to Available
  to implement ConditionTester

* isset

  checks whether another property is set

* istrue

  checks whether another property is set and evaluates to true

* equals

  compares to Strings with a Syntax similar to KeySubst. The separator
  char could be the first char. Something like

  <setunless equals="*${jdbc.version}*1.0" property="files.to.ignore" 
        value="*1_0*" />
  <setunless equals="*${jdbc.version}*2.0" property="files.to.ignore" 
        value="*2_0*" />

  would make it easy to conditionally phase out files from
  compilation.

* javaversion

  some way to check the JVM version at (ant-) runtime. Maybe make this 
  three built-ins javaversionequals, javaversiongreater,
  javaversionless.

* isexecutable

  checks whether a given command can be executed. 

  I can't think of a portable way to implement this without actually
  running the command.

I have already implemented such Tasks and most of the proposed
built-ins but the code would need some brush up before I submit it. My
primary goal is to get feedback on this first.

Stefan

Mime
View raw message