You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by James Cook <ji...@iname.com> on 2000/10/27 16:54:42 UTC

Using the property tag to handle globals

I have a project that consists of subprojects, very much like the Tomcat build.
Tomcat has a build script in it's source directory that invokes (using <ant>)
build scripts in a few subdirectories. This is exactly how I want my build to
work.

I have tried to improve the use of properties by creating a "global.properties"
file that exists in the root of my build hierarchy (i.e. the "src" directory in
Tomcat). Some properties that I have set in this file are derived, but all are
derived from absolute paths. Below is an excerpt from this global.properties
file:

dist=/projects/pas2000/dist
broker.jar=${dist}/lib/broker.jar

I mention this because my root build script *and* the build scripts for my
subprojects all refer to this global properties file, to eliminate the duplicate
definition of property values that Tomcat uses. I can do this because unlike
Tomcat, my distribution property (dist) is absolute and not relative.

If I run the build process in any of my subprojects, everything builds fine. I
figured my root build script would simple delegate to each subproject build
script, but I am experiencing unusual results. My root build script looks like
this:

<project name="my project" default="dist" basedir=".">
    <property file="globals.properties"/>
    <target name="dist">
        <ant dir="./uid" target="dist"/>
    </target>
</project>

The build script for the uid subprojects has some lines like this:

<project name="uid" default="all" basedir=".">
    <property file="../globals.properties"/>
    <property name="build" value="${basedir}/classes"/>
    <target name="prepare">
        <echo message="The basedir is: ${basedir}"/>
        <echo message="The build is: ${build}"/>
        <mkdir dir="${build}"/>
    </target>
</project>

When I run the build from the uid directory, I get the following correct output:

The basedir is: D:\projects\pas2000\projects\uid
The build is: D:\projects\pas2000\projects\uid/classes
    [mkdir] Created dir: D:\projects\pas2000\projects\uid\classes

However, when I invoke the uid build script from my build root (and it is
invoked using the <ant> tag, I get these results:

The basedir is: ./uid
The build is: ./uid/classes
    [mkdir] Created dir: D:\projects\pas2000\projects\uid\uid\classes

Notice the duplicate "uid\uid" in the mkdir output. This is the root of my
troubles. I have tried to play with the <ant> parameters for "dir" and "antfile"
with no luck. Why does basedir behave so strangely, and is it a bug?

thanks,
jim




RE: Using the property tag to handle globals

Posted by James Cook <ji...@iname.com>.
No, it is Ant 1.2

jim

> -----Original Message-----
> From: Stefan Bodewig [mailto:bodewig@bost.de]
> Sent: Friday, October 27, 2000 11:28 AM
> To: ant-user@jakarta.apache.org
> Subject: Re: Using the property tag to handle globals
> 
> 
> >>>>> "JC" == James Cook <ji...@iname.com> writes:
> 
>  JC> However, when I invoke the uid build script from my build root
>  JC> (and it is invoked using the <ant> tag, I get these results:
> 
>  JC> The basedir is: ./uid
> 
> Jim, is this Ant 1.1 or 1.2? relative versus absolute file names has
> been one of the problems that are supposed to be fixed by Ant 1.2.
> 
> Stefan
> 

Re: Using the property tag to handle globals

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "JC" == James Cook <ji...@iname.com> writes:

 JC> However, when I invoke the uid build script from my build root
 JC> (and it is invoked using the <ant> tag, I get these results:

 JC> The basedir is: ./uid

Jim, is this Ant 1.1 or 1.2? relative versus absolute file names has
been one of the problems that are supposed to be fixed by Ant 1.2.

Stefan