Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

append /classes to each entry in a dirset

 
Dave Boden
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dave Boden
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ended up doing this:



Works nicely. Phew.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Interesting. Thanks for sharing this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic