ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <>
Subject [PROPOSAL] Enhancement to available task
Date Wed, 03 Jan 2001 01:30:55 GMT

In reading the ant-user and ant-dev lists for a few months now and seeing
some of the issues related to conditional support in Ant, I recently came
up with some ideas related to improving the conditional support in Ant
while trying to be consistent with the goals of the Ant maintainers of
keeping Ant's XML more declarative in nature.

It's common to use the <available> task to set a property based on the
availability of a class which is then used at the target level to execute
or not execute a target based on the if/unless attributes.  The problem is
that often more than one class may need to be available before a target
should be executed.  Currently, you have to use a convoluted means of
extra targets and property settings to support this.  This non intuitive
scheme makes the build.xml more complicated and harder to maintain, etc.

So then, why not add support to the <available> task so it can check for
the availability of one _or more_ classes?  The idea is to allow
specifying multiple class names separated by commas in the "classname"
attribute.  When more than one class name is specified, they all must be
present for the property to be set.  For instance, the following would set
the property javascript.present only if both BSF and Rhino were available:

  <available property="javascript.present"
org.mozilla.javascript.Scriptable" />
  <target name="run_script" if="javascript.present">
    <script language="javascript">
  <target name="no_javascript" depends="run_script"
    <fail message="JavaScript is not available ..."/>

One issue is the "classname" attribute is singular.  With this
enhancement, maybe a plural "classnames" attribute should be considered?

-Bill Burton

View raw message