views:

25

answers:

1

I'm exploring the awesomeness of Ant 1.8.1's import ability. Here's my situation: I have a top-level Ant file (project.xml) that turns around and calls ant on another Ant file (say, neato_project.xml) which actually does the build, or clean or whatever.

I have 12 different project files that this top-level (project.xml) file can call, so I want to put a common classpath entry into the project.xml file that I can pass to the others to use as their individual classpaths.

How do I do that? I've been trying to play with import task, but I haven't gotten that figured out. I'm open to another approach if there's a better way to approach this problem in Ant.

+1  A: 

Import wasn't introduced in 1.8; it was enhanced in 1.8. This is good because it means people like me have a couple years experience with import.

What I do:

  1. constants.xml - the common strings and classpaths my build uses
  2. build.xml - the main file imports #1 and #3
  3. helper-project-1.xml - it has a clearer name, but that's hardly the poing
  4. helper-project-2.xml, etc

I use this approach because I want build.xml to pass the constants. I only keep them in a separate file for readability.

Jeanne Boyarsky
Thanks for the clarification. Your approach sounds like it's just what I'm looking for. Would you please point me to a simple and specific example on how to import those files?
Dopyiii
Not to cite the manual, but I'm not doing anything complicated. Just<import file="${workspacedir}/${buildProject}/constants.xml" />
Jeanne Boyarsky