I'm trying to simplify my ant build files. I have multiple projects, many of which are similar and have similar dependencies.
For example, I have sets of jar files that need to be operated upon within each project build file. These jars need to become part of the classpath during the compile phase, and need to be copied to WEB-INF/lib during the deploy phase.
Here's what I'd like to achieve:
1) Factor as much as possible out of the individual project build files into a common imported file used across multiple projects. 2) Use a set of jar files from disparate locations as part of the classpath. 3) Copy that set of jar files to a single location (WEB-INF/lib). 4) Specify the set of files once, and use referencing elsewhere.
I'm using Ant 1.6.2 so macros can be part of the solution if need be.
One wrinkle is that the location and the name of the jar files needs to be parameterized via a property that is specific to each project (as each project may have a dependency on different version of the library).
Let's say for example that there are two libraries: abc and xyz. The file structure would be:
Where abc.version and xyz.version are per-project properties identifying the dependent versions.
I tried setting up path elements as follows (there are properties that factor out hard-coded settings, but they're not relevant here so I removed them in favor of hard-coded vlaues for the purpose of the discussion):
and that worked fine for the classpath of the javac task:
but failed when I tried to use it in a copy task. The copy task needs a fileset, and I found no way to use the defined path to create a fileset, and no way to assign an id to a fileset so it could be reference from multiple locations:
So, I figured I'm doing it all wrong.
Given my objectives, is there a way to construct paths, filesets and patternsets that meet them?