I'm faced with a bunch of build.xml files in several directories,
all of them define a certain target (say: T). The definition of
this target in all these build files are structurally nearly the same.
Their implementations differ only in small details, say, a different
value for some filename etc. During one build, all these targets are
executed by recursive calls of Ant.
Maintaining this is a nightmare, because every change of logic has to
be repeated in every build file, so I'm looking for away to have
only one copy of them.
Using an ENTITY declaration in the DOCTYPE and including these repeated
parts with &... does not work, because they are not completely identical.
Using properties as parameters for the differing bits does not work
either, because I can not change a property as soon as it is set once.
Of course I could write a new Ant task in Java, and pass the differing
values as attributes, but this seems to be an overkill for such a
seemingly simple problem.
Any ideas?
Ronald
Robert Klemme - 26 Nov 2003 14:57 GMT
> I'm faced with a bunch of build.xml files in several directories,
> all of them define a certain target (say: T). The definition of
[quoted text clipped - 6 lines]
> be repeated in every build file, so I'm looking for away to have
> only one copy of them.
You could put all property definitions for the sub build.xml in a file per
sub project and initialize the properties in task <ant>.
> Using an ENTITY declaration in the DOCTYPE and including these repeated
> parts with &... does not work, because they are not completely identical.
> Using properties as parameters for the differing bits does not work
> either, because I can not change a property as soon as it is set once.
But you can set a property for a recursive ant call! See the attribute
"inheritAll" @ http://ant.apache.org/manual/CoreTasks/ant.html
> Of course I could write a new Ant task in Java, and pass the differing
> values as attributes, but this seems to be an overkill for such a
> seemingly simple problem.
Cheers
robert
Stefan Bodewig - 27 Nov 2003 09:17 GMT
> I'm faced with a bunch of build.xml files in several directories,
> all of them define a certain target (say: T). The definition of
> this target in all these build files are structurally nearly the same.
> Their implementations differ only in small details, say, a different
> value for some filename etc. During one build, all these targets are
> executed by recursive calls of Ant.
Use Ant 1.6beta and <import>.
For some doc examples that go beyond the current documentation inside
the beta distribution see
<http://nagoya.apache.org/wiki/apachewiki.cgi?NewAntFeaturesInDetail/Import>
and
<http://marc.theaimsgroup.com/?l=ant-dev&m=106934667616938&w=2>
Stefan
Ronald Fischer - 28 Nov 2003 09:52 GMT
> Use Ant 1.6beta
Unfortunately I have to stick with 1.5.3 :-(
At least I know now that I can't find a workaround in the version
I have to use, so I'll stick with duplicated code everywhere....
Ronald