ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: project basedir
Date Thu, 20 Feb 2003 10:45:09 GMT
I would although be careful when passing relative values for basedir from
command line.  The value used by Ant will also depend on the current working
directory when running Ant.  Take this setup for example:  I have this
buildfile stored as D:\Temp\test.xml:

<project name="test" default="test" basedir=".">
    <target name="test">
    	<property name="base" location="${basedir}"/>
        <echo>basedir=${base}</echo>
    </target>
</project>

Now invoking from D:\ yields:
----------------------------------------------------------------------
D:\>ant -Dbasedir=.. -f Temp\test.xml
Buildfile: Temp\test.xml

BUILD FAILED
Cannot resolve path D:\\..

Total time: 1 second

D:\>ant -Dbasedir=. -f Temp\test.xml
Buildfile: Temp\test.xml

test:
     [echo] basedir=D:\

BUILD SUCCESSFUL
Total time: 1 second
----------------------------------------------------------------------

And invoking from D:\Temp yields:
----------------------------------------------------------------------
D:\Temp>ant -Dbasedir=.. -f test.xml
Buildfile: test.xml

test:

BUILD FAILED
file:D:/Temp/test.xml:3: The file or path you specified (..) is invalid
relative to D:\

Total time: 1 second

D:\Temp>ant -Dbasedir=. -f test.xml
Buildfile: test.xml

test:
     [echo] basedir=D:\Temp

BUILD SUCCESSFUL
Total time: 1 second
----------------------------------------------------------------------

I don't know if this should be regarded as a bug or not.  But I have had
this kind of problems, so I try to stay away from passing values for basedir
from command line.  Especially relative paths.

--
knut

> -----Original Message-----
> From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> Sent: Donnerstag, 20. Februar 2003 11:19
> To: user@ant.apache.org
> Subject: AW: project basedir
> 
> 
> I think it depends on the order in which this special property is set:
> during parsing time
> of the build file BEFORE loading the properties-file.
> 
> But you should be able to set a different one by invokint Ant:
> 	ant -Dbasedir=c:\development ...
> 
> One momen - a small test ...
> ... jepp:
> 
> <project name="test" default="test" basedir=".">
>     <target name="test">
>         <echo>basedir=${basedir}</echo>
>     </target>
> </project>
> 
> ant
> test:
>      [echo] basedir=C:\temp
> 
> ant -Dbasedir=..
> test:
>      [echo] basedir=..
> 
> ant -Dbasedir=c:\development
> BUILD FAILED
> Basedir C:\development does not exist
> 
> ant -Dbasedir=c:\winnt
> test:
>      [echo] basedir=c:\winnt
> 
> 
> 
> Maybe you write a wrapper script which evaluates an 
> environment variable or
> so...
> 
> 
> Jan Matèrne
> 
> > -----Urspr√ľngliche Nachricht-----
> > Von: Matthew Oatham [mailto:matthewoatham@hotmail.com]
> > Gesendet am: Donnerstag, 20. Februar 2003 11:15
> > An: user@ant.apache.org
> > Betreff: project basedir
> > 
> > Hi,
> > 
> > I need my project to be able to take different basedir values i.e.
> > 
> > <project ... basedir="c:\code">
> > <project ... basedir="c:\development">
> > 
> > depending on a users setup. Therefore I thought I would 
> > specify basedir in a properties file that coould be changed 
> > by users depending on there set-up. 
> > 
> > i.e 
> > 
> > <project ... basedir="${someProperty}">
> > 
> > someProperty=c:\code
> > 
> > However this didn't work so I tried, as suggested by others, 
> > removing the basedir attribute and putting it in a properties 
> > file i.e.
> > 
> > <project ...>
> > 
> > basedir=c:\code
> > 
> > Again this still didn't pick up the basedir.
> > 
> > Has anyone managed to do this?
> > 
> > Regards.
> > 
> > Matt.
> > 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message