ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: [Ant 1.6beta1] More feedback about import
Date Thu, 16 Oct 2003 16:43:26 GMT
On Thursday 16 October 2003 16:04, Dominique Devienne wrote:
> > From: peter reilly [mailto:peter.reilly@corvil.com]
> >
> > 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).
>
> So, where does that leave us? Will 'required' be added to <import>?

I think that it should be added.
To use <import> in the same way as <property file="x"/> is used
one would need an attribute to specify the import is optional.

Use of <macrodef> in this case is an experiment to see what
nits are left in the implementation.

>
> As far as the problem you describe above, this is exactly why I argued
> against this un-intuitive de-referencing of properties in <macrodef> so
> vehemently...

Mmm..
not quite, the problem is due to the available file attribute being a File
and the import file attribute being a String and interperted differently.

The correct solution is to use <trycatch>, but this is noisy - it needs 
a quiet attribute to suppress the "Caught exception" message.

  <macrodef name="conditional-import">
    <attribute name="file"/>
    <sequential>
      <ac:trycatch quiet="yes">
        <try>
          <import file="${file}"/>
        </try>
        <catch/>
      </ac:trycatch>
    </sequential>
  </macrodef>


>
> OK, but beside that, what would happen if the <macrodef> was in my
> antlib.xml. I am rather confused about what *should* happen.

In this case what should work does not (grrr).
The import task resolves a relative file attribute from the antlib file
and not the file that contains the conditional-import task.

The problem, is that the macro does not set the location
attribute of the tasks it runs.

If it sets them, some error messages would make less sense than they
do at the moment (and some more).

However, the it is most likely more correct to set the location.

Peter



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message