ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <>
Subject Re: <path> and <classpath> - interchangeable?
Date Mon, 23 Aug 2010 22:19:09 GMT
Stefan Bodewig schrieb am 23.08.2010 um 06:05 (+0200):
> On 2010-08-23, Michael Ludwig wrote:
> > I'm wondering what's the difference between <path> and <classpath>.
> > Why are there these two construct? Aren't they functionally
> > identical?
> Ant contains a type - a thing you can define outside of tasks - called
> <path>.  This Ant type is backed by a Java class named Path.
> Some tasks support nested elements that are implemented by that same
> Java class.  Some tasks class it <path>, others call it <classpath>
> and there are even more names used by tasks.
> This means that you can use <path id="foo"> somewhere outside of a
> task and use that via <classpath refid="foo"/> in a task that calls
> its nested element <classpath>.

Very good! I think I got it:

<project default="build">
  <property name="dest.dir" location="dest"/>
  <path id="class-path"><!-- This must be <path>, not <classpath>! -->
    <pathelement location="lib"/>
  <target name="build">
    <javac srcdir="src" destdir="dest" classpathref="class-path"
    <!-- Genauso gut geht es so: -->
    <javac srcdir="src" destdir="dest" includeAntRuntime="no">
      <classpath refid="class-path"/>

> > Is it correct to say that the whole <path>/<classpath> thing can be
> > explained historically by reference to the <javac> task? Which sports
> > @classpath, @sourcepath, @bootclasspath and @extdirs, all <path> types?
> Not really.
> <javac> is a good example, it needs four different types of path
> structures so it needs four different names for them.

Good point. :-)

> For the thing you can define outside of tasks, we need only one name
> and <path> is the most generic one.
> > So are <path> and <classpath> interchangeable?
> Structurally, yes.  But if the task calls its nested element
> <classpath> then you have to use that name and can't call it <path>.

And you have to use <path> if you want to refer to the path
structure by, say, javac/@classpathref. You cannot refer to
some classpath/@id, it has to be path/@id.

Perfect, you've made it clear to me know! Thanks!
Michael Ludwig

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message