File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes append /classes to each entry in a dirset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "append /classes to each entry in a dirset" Watch "append /classes to each entry in a dirset" New topic
Author

append /classes to each entry in a dirset

Dave Boden
Ranch Hand

Joined: Nov 08, 2000
Posts: 37
I have a dirset called projectDependencies. What I'd like to do is take each of the entries in this dirset and append /classes to it. At the moment, I'm resorting to having another dirset where I've copied and pasted the entries and added /classes. Yuck.

Without using <foreach> or another non-standard tag, is there a way of appending something to every entry in a "path-like structure"?

----

<dirset id="projectDependencies" dir="..">
<filename name="ss_base_shared"/>
</dirset>

<dirset id="projectDependenciesClasses" dir="..">
<filename name="ss_base_shared/classes"/>
</dirset>

<path id="requiredLibraries">
<filelist dir="..">
<file name="SSSharedLibrary/lib/buildandruntime/all_netscape.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/itc.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/jms.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/jnlp.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/junit.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/security_ie.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/tibjms.jar"/>
<file name="SSSharedLibrary/lib/buildandruntime/utils.jar"/>
</filelist>
</path>

<target name="build" depends="init"
description="Builds this project and the projects upon which this project is dependent">
<echo message="Building ${ant.project.name}"/>

<echo message="Building project dependencies..."/>
<subant antfile="build-london.xml" target="build">
<dirset refid="projectDependencies"/>
</subant>

<javac srcdir="src"
destdir="classes"
classpathref="requiredLibraries"
source="1.4"
target="1.4">
<classpath>
<dirset refid="projectDependenciesClasses"/>
<path refid="requiredLibraries"/>
</classpath>
</javac>
</target>

----
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

You could eliminitate a bit of duplication with:


This protects you from change if the name changes. It is of only minimal help if you have a long list of things or the number of things changes.

I don't know of a way to avoid all duplication without foreach or bean shell scripting.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Dave Boden
Ranch Hand

Joined: Nov 08, 2000
Posts: 37
I ended up doing this:



Works nicely. Phew.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Dave,
Interesting. Thanks for sharing this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: append /classes to each entry in a dirset
 
Similar Threads
Builded file using clientgen does not have my jar files
ant exception
Builded file using clientgen does not have my jar files
Build problem when including third party jars in classpath using ant
Problem in adding jar files to the building war file using ant