aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant: Difference between fileset and pathelement tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant: Difference between fileset and pathelement tags" Watch "Ant: Difference between fileset and pathelement tags" New topic
Author

Ant: Difference between fileset and pathelement tags

Jay George
Greenhorn

Joined: Jul 28, 2004
Posts: 5
Today, I was compiling some java files with an ant script. I wanted to include a combination of jar files and class files on javac's classpath.

Originally, I included those class files in a <fileset>. Unfortunately, my build failed with errors because it couldn't see the required class files. However, once I changed the tag from fileset to "pathelement", the class files got picked up, and my build succeeded.

So my question is, what is the difference between "fileset" and "pathelement"? And why do the class files need to be included in a <pathelement> instead of <fileset>? I googled around for the answer, but couldn't find any satisfactory explanation.

Thanks.

FYI, my javac structure (the one that compiles successfully) looked similar to this:
<javac srcdir="src" destdir="build">
<classpath>
<pathelement path="${OtherApp.builddir}/classes" />
<fileset dir="tomcat/abc/lib" includes="*.jar"/>
<fileset dir="tomcat/xyz/lib" includes="*.jar"/>
</classpath>
</javac>
Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
A pathelement is taken more or less literally to be included in the path. A fileset, on the other hand, builds a list of all the files that match - that is, every single class file found would be mentioned with its full path. The latter obviously isn't something the JVM does understand.

Did that help?
Jay George
Greenhorn

Joined: Jul 28, 2004
Posts: 5
The latter (in reference to fileset of classes) obviously isn't something the JVM does understand.


How come the JVM understands the fileset of jar files, but not the fileset of class files?
Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
Originally posted by J. George:


How come the JVM understands the fileset of jar files, but not the fileset of class files?


Actually a jar file isn't that different from a root directory conceptually. It too contains a lot of class files in sub directories (that match the package structure). You don't put every single class file from the jar into the classpath.

The difference is that for Ant, a jar file is a single file - it doesn't know that it contains whole directories of class files.

Does that help?
Jay George
Greenhorn

Joined: Jul 28, 2004
Posts: 5
Yeah, that explains it. Thanks.
Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
Originally posted by J. George:


How come the JVM understands the fileset of jar files, but not the fileset of class files?


BTW, the JVM doesn't understand filesets. Ant does resolve them and builds a single classpath string that gets passed to the JVM - just as you would do using the -cp switch. (You can see this by running Ant using the "-verbose" switch.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant: Difference between fileset and pathelement tags