You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Michael Ludwig <mi...@gmx.de> on 2010/08/23 02:27:55 UTC

and - interchangeable?

I'm wondering what's the difference between <path> and <classpath>.
Why are there these two construct? Aren't they functionally identical?

This is not about the environment variables, but about the Ant
constructs.

The question has been asked here, but not really answered:

difference between path,pathelemnt,classpath and fileset tags
http://marc.info/?l=ant-dev&m=124419759524145&w=2

And also here:

path classpath
http://ant.1045680.n5.nabble.com/path-classpath-td1353146.html

This time, the answer is: "There is no difference in type."

If this is so, it wouldn't hurt to state that in the manual. Looks like
there is no dedicated reference page for these constructs, but examples
for <path> and <classpath> are given here:

http://ant.apache.org/manual/using.html#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?

http://ant.apache.org/manual/Tasks/javac.html

So are <path> and <classpath> interchangeable?

-- 
Michael Ludwig

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


Re: and - interchangeable?

Posted by Michael Ludwig <mi...@gmx.de>.
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"/>
  </path>
  <target name="build">
    <javac srcdir="src" destdir="dest" classpathref="class-path"
      includeAntRuntime="no"/>
    <!-- Genauso gut geht es so: -->
    <!--
    <javac srcdir="src" destdir="dest" includeAntRuntime="no">
      <classpath refid="class-path"/>
    </javac>
    -->
  </target>
</project>

> > 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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: and - interchangeable?

Posted by Stefan Bodewig <bo...@apache.org>.
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>.

> 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.  For <exec> the
name <path> is the natural one.

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>.

Stefan

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