ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John P. McGrath" <JPMcGr...@JPMcGrath.net>
Subject RE: Common path definitions
Date Tue, 10 Jul 2001 02:23:00 GMT
Thank you all for your replies.

> Sounds to me like your problem is you need a standard place to
> put your properties file.  That way, no matter what platform or
> system the file is on, Ant will always be able to find it, and use
> it to locate various libraries.

I don't see that as a major problem.  I can require that the external
environment provide a property which points to a file.  I can also provide a
"reasonable" default value in the "build.xml" file, so in many cases it
would not be necessary to specify it.

The problem is in the structure of the common definitions.  They consist of
a number of paths, so ideally I would like to define them as <path>
elements.  For example:

    <path id="foo.path">
        <pathelement location="/usr/java/libraries/foo.jar" />
    </path>

    <path id="bar.path">
        <pathelement location="/usr/java/libraries/bar1.jar" />
        <pathelement location="/usr/java/libraries/bar2.jar" />
    </path>

I can find no effective way to store these definitions in a separate file
and then use those definitions in various "build.xml" files.

I can "include" the file into other files by defining an XML entity to be
equal to the contents of the file, but I can find no way to specify the
location of that file in terms of a property.

And I can find no way to tell Ant to use the <path> elements defined in
another file.

I could store the information as property strings, and then define the
<path> elements in each build file that needs to use them, but that is what
I am trying to avoid.

Regards,

John McGrath

-----Original Message-----
From: Kyle Adams [mailto:kadams@gfs.com]
Sent: Monday, July 09, 2001 2:13 PM
To: ant-user@jakarta.apache.org
Subject: Re: Common path definitions

Sounds to me like your problem is you need a standard place to put your
properties file.  That way, no matter what platform or system the file is
on, Ant will always be able to find it, and use it to locate various
libraries.

If this is the case, then you might be able to make use of the ${user.home}
"magic variable" in Ant.  ${user.home} always points to the user's home
directory.  For example:

Win NT      ${user.home} = c:\winnt\profiles\USERNAME
*nix           ${user.home} = /home/USERNAME

In the build.xml file:

<property file="${user.home}/build.properties" />

Now, as long as your developers are sure to put the build.properties file in
their home directory, Ant will be able to find it, no matter what system or
platform its on.  There are some caveats to this approach:

1) It assumes requiring your developers to place the properties file in
their home directory is a reasonable request.  It should be easy to use your
configuration management system (be it CVS, VSS, or whatnot) so that a
standard configuration file is available for everyone to checkout.

2) It assumes your developers know where their home directory is.  If this
is a problem, simply have your init target (you do have one, don't you?)
echo the ${user.home} variable.

Kyle

>>> JPMcGrath@JPMcGrath.net 07/09/01 01:49PM >>>
I have been having a tough time setting up Ant files the way I want, and am
hoping someone can suggest an approach that will work.

I have a number of projects for which I am creating Ant build files, and
each of these projects use some number of third-party libraries.  I have to
be able to build the projects on a number of different platforms and
systems, and the paths to the library files are different on the different
systems.

I would like to create a single file that defines where the libraries are.
Ideally, this would consist of a number of path elements that points to the
JAR file(s).  Then I would like to "include" this single library definition
file into the build files for the projects.  The location of the library
definition file will vary from system to system, so I would like to pass the
name of that file to the build file as a property.

I have tried using an XML entity to include the file, but I cannot find any
way to parameterize the path to that file.  I have also tried "running" the
library definitions using the <ant> task, but that does not seem to work
either.  I can execute tasks in the file, but the paths are not available in
the calling script.

Does anyone have an idea how to accomplish this?

Regards,

John McGrath




Mime
View raw message