ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: ant 1.5.4 : Import
Date Thu, 24 Jul 2003 14:19:12 GMT

Conor MacNeill wrote, On 24/07/2003 14.49:

> On Thu, 24 Jul 2003 10:26 pm, Nicola Ken Barozzi wrote:
> 
>>What about:
>>
>>  <import file="blah.xml" name="blah"/>
> 
> Sure - pretty much what I thought, maybe a more descriptive attribute name 
> (overrideprefix). It would default to the imported project name.

A bit long...

What about this, it seems descriptive enough IMHO.

  <import file="blah.xml" prefix="blah"/>

or

  <import file="blah.xml" use-prefix="blah"/>

>>So IIUC it's really only about making the import task resolve files
>>relative to the basedir of the project that imports, as you say above.
> 
> Yes. This is how Ant works for other tasks so it should work that way for 
> import too. The resolution does have to be done in Import itself using a 
> String argument since the default File argument would be resolved by Ant to 
> the outermost project's basedir which would be wrong.

Well, import already uses a String argument but does the following:

    // Paths are relative to the build file they're imported from,
    // *not* the current directory (same as entity includes).
    File importedFile = new File(file);
    if (!importedFile.isAbsolute()) {
        importedFile = new File(buildFileParent, file);
    }

I reckon that this change would resolve to the initial basedir, right?

    File importedFile = new File(getProject().resolveFile(file));
    if (!importedFile.isAbsolute()) {
        importedFile = new File(buildFileParent, file);
    }

Don't have time to try it ATM :-(

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------



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


Mime
View raw message