ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <>
Subject Re: [Ant 1.6beta1] More feedback about import
Date Thu, 16 Oct 2003 14:56:58 GMT
I suppose one add a required attribute.
One could also use a macrodef which nearly works.

<project xmlns:ac="antlib:net.sf.antcontrib">
  <macrodef name="conditional-import">
    <attribute name="file"/>
        <available file="${file}"/>
          <import file="${file}"/>

  <conditional-import file="imported.xml"/>
  <conditional-import file="not-present.xml"/>

The only problem with this is that the resolution of file for
available is relative to base dir and the resolution of file for
import is relative to the file that contains the import task (or
in this case the conditional-import task).

On Thursday 16 October 2003 15:23, Dominique Devienne wrote:
> Peter, and al,
> I'd like <import> to have a new 'required' attribute that I could set to
> false to simply ignore an imported build file not found. Before I get
> flamed, here's the use case: rich and flexible user-configuration of the
> build.
> Currently, each project loads a properties file from
> users/${}/${} This allows to set
> various properties of course, but only properties used by the build file
> are useful. It's not easy to define paths, etc... Of course, such a
> user-specific properties is optional, and Ant merrily ignores that fact.
> I'd like to change this pattern so that now each project imports an
> optional users/${}/${}-build.xml file, which can
> thus contain properties, but also any tasks or even additional targets
> specific to a user (for example as a VIM user, a tasks that runs ctags on
> the project).
> With this pattern, and the new <presetdef>, a user can even configure task
> attributes which have not been defaulted and used thru a property
> (something I complained about, and that <presetdef> addresses quite
> nicely).
> Lastly, but quite importantly for us with platform-specific issues related
> to native code, such an imported user-specific XML file can use conditions
> from Ant-Contrib to conditionally set properties, something one had to
> resort to emulate thru loading this or that file, which was quite
> cumbersome.
> I truly hope the benefits that such a use case presents will be enough for
> this minor additional to make it to Ant 1.6.
> Thanks, --DD
> C:\oss\org_apache\antx\import16>ant -version
> Apache Ant version 1.6beta compiled on September 30 2003
> C:\oss\org_apache\antx\import16>ant -f import-not-found.xml
> Buildfile: import-not-found.xml
> C:\oss\org_apache\antx\import16\import-not-found.xml:5: Cannot find
> does/not/exist.xml imported from
>  C:\oss\org_apache\antx\import16\import-not-found.xml
> Total time: 1 second
> C:\oss\org_apache\antx\import16>type import-not-found.xml
> <?xml version="1.0"?>
> <project>
>   <import file="does/not/exist.xml" />
> </project>
> C:\oss\org_apache\antx\import16>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message