Many moons ago a way of dealing with large and sprawling projects using make was to split up the project into many smaller parts and use a set of make rules that lent themselves to a hierarchical structure of Makefiles. Now I'm using and and getting to the stage with it that the projects are getting larger and larger and all the rules for building are stuck into a single build.xml file that is getting a bit too large. What I would like to do would be to use a hierarchical structure of build.xml files, which relied upon a single set of rules. But ant doesn't seem to work like that. Has anyone tackled this problem before and found a satisfactory solution to it?
U can do that. Say you have separate build files for different modules (for eg: "build-module2.xml","build-module3.xml") You can call it form within a main build file like this: <target name="hello"> <ant antfile= "build-module2.xml"/> </target> <target name="hello"> <ant antfile= "build-module3.xml"/> </target> .. [/CODE] HTH
Ant was, in fact, designed with things like that in mind. If you look close at the docs, you'll notice that in certain cases, Ant will even look "uphill" for build instructions. In practical terms, I'm using both the <ant;> and <antcall> features to assist me in building and maintaining complex websites daily.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Sep 26, 2000
If that's the case maybe I should look at this again. Let me explain what I was looking at doing... What I wanted to do was to build a hierarchical set of build.xml files. The root build.xml file would define a set of tasks which the leaf build.xml files would rely upon, in the sense that they could directly call the tasks defined at the root using the <antcall> task. Tim, is that the kind of thing that you are doing? It seems to me that if it's not possible it would lead to an awful lot of duplication when the leaf build.xml file tasks have a lot in common. As you say, in certain cases, Ant will even look "uphill" for build instructions. Which cases are those? I'll clarify the sort of thing that I wanted to do ... build.xml
Both default targets are called, but when I try to call back to the original file, to the xyz target, it complains of not finding the target within the current project. Can I use multiple files within the same project or am i forced to use multiple projects?
Here's the official from the Ant 1.5 docs on "uphill" searches:
These files DO have a lot of duplication, in part because they're automatically generated, but it's supposed to be possible to make subproject code that would look something like this:
Refer to the <ant> task's docs for info on what gets used as the reference directory for relative paths. I'd probably put sub-tasks in alternative buildfiles rather than in the main build.xml, but it would depend on the overall shape of the project and how wierd I was the day I laid it all out. [ September 27, 2002: Message edited by: Tim Holloway ]
Thanks for all replies, I shall certainly make use of those tips and tricks when I split out my increasingly unwieldy single ant build.xml file. Does "Configure" on this page sound like what you want ? yes, thanks Frank, looks like just the thing I'm looking for. Not sure about the only 'compatible with ant 1.2 or 1.3' bit as I'm using the 1.5 version at the moment but I'll certainly try it, and maybe I can adapt it.