ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@bost.de>
Subject Re: Newbie question
Date Fri, 11 Aug 2000 08:14:52 GMT
>>>>> "SD" == Sills, David <David.Sills@appnet.com> writes:

 SD> I'm new to using Ant and am finding the documentation totally
 SD> inadequate at answering obvious questions that would be asked by
 SD> new users.

Once you've become familiar with Ant you're more than welcome to help
out with this 8^).

 SD> I have some gnumake experience and some JMake experience,

This seems to be one of the greatest obstacles to using Ant, having
make experience. Don't take this personally, it's just a general
observation.

 SD> It is possible to set a classpath within the build.xml file,

Not really. What you see in Ant's own buildfile

<property name="classpath" value="" />

is just the definition of a property named classpath. There is no
magic connected to that name, Ant is not going to use anything you put
in here unless you tell it to do so.

Tasks that could use a classpath usually have an attribute for this
and most of them have nested <classpath> elements. The system
classpath (the one Ant has been invoked with) can be found in the
property java.class.path.

If you need to specify a different classpath in some task, start by
defining a property for it, let's call it base.classpath, to make it
easy to define it differently for different users, do so using command
line arguments:

ant -Dbase.classpath=whatever

and to make this more convenient to your developers, define the
environment variable

ANT_OPTS=-Dbase.classpath=whatever

this is going to be evaluated by the ant and ant.bat scripts.

Now, lets say you need to use this classpath in a <javac> task:

<javac ...>
  <classpath>
    <pathelement path="${base.classpath}" />

    <!-- maybe add some classes that are common to all developers -->
    <pathelement location="${common.classes.dir}" />

    <!-- throw in the system classpath as well -->
    <pathelement path="${java.class.path}" />

    <!-- Ant > 1.1 only, just as a teaser.
         add all .jar files in lib/ relative to project's basedir -->
    <fileset dir="lib/">
      <include name="**/*.jar" />
    </fileset>
  </classpath>
</javac>

Does this do what you want to achieve?

Stefan

Mime
View raw message