ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <peter.kitt.rei...@gmail.com>
Subject Re: Relative Paths in Imported Files
Date Tue, 26 Aug 2008 13:08:07 GMT
On Sun, Aug 17, 2008 at 9:18 PM, Francisco Tolmasky <tolmasky@gmail.com> wrote:
> I have a common.xml file that I import in all my build.xml throughout my
> project (subdirectories included).  One of the tasks defined in this
> common.xml has to reference a file in a java task, as so:
>
>    <macrodef name = "my-tasl">
>
>        <element name = "arguments"/>
>
>        <sequential>
>            <java classname = "blah..Main" >
>                <classpath>
>                    <pathelement location = "../Jars/thejar.jar" />
>                    <pathelement location = "." />
>                </classpath>
>
>                <arguments/>
>            </java>
>        </sequential>
>    </macrodef>
>
> Unfortunately, this only works from certain directories, since the
> pathelement location is relative.  Is there any way to make a relative file
> path from the location of the common.xml file itself?

There is a magic property associated with each imported build file
which contains
the name of the build file. This is ant.file.NAME_OF_PROJECT_OF_BUILD_FILE.
This gets set if the build file has a name attribute and this name is
unique in the set
of imported build files. One can use the <dirname> task to get the directory
of the build file.

For example:

<project name="common">
   <dirname property="common.dir" file="${ant.file.common}"/>
</project>

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

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


Mime
View raw message