Re: How to parameterize similar targets?

From: Robert Klemme (bob.news_at_gmx.net)
Date: 11/26/03


Date: Wed, 26 Nov 2003 15:57:51 +0100


"Ronald Fischer" <ronaldf@eml.cc> schrieb im Newsbeitrag
news:219750c.0311260645.46d2233a@posting.google.com...
> 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.

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



Relevant Pages

  • Re: Ant Problem
    ... ok, also wenn ich Dich richtig verstanden habe Ant sucht nach "init" und auf Grund dessen baute sich eigne Struktur, ... Gibst du Ant beim Start den Namen eines Target als Parameter mit, dann sucht Ant dieses Target. ... Warum startest du den Tomcat aus dem 'clean' target heraus?!? ...
    (de.comp.lang.java)
  • Re: Games for March
    ... You have to jab the fire button just as they fly over the target. ... when you enter the nest. ... gu;ped down by an exiting ant is very tricky, aside form that you have to ...
    (comp.sys.amiga.games)
  • Re: Ant Problem
    ... Gibst du Ant beim Start den Namen eines Target als Parameter mit, ... Anweisung abarbeiten ohne es auf die anderen ... und die jar Archive im Tomcat Verzeichnis zur "holen". ...
    (de.comp.lang.java)
  • Re: Ant Problem
    ... compile, dann jar, dann clean, ohne Erfolg, danach habe ich versucht den target "build-clean" ohne ... ant task calling a target that depends on its parent target 'jar'. ...
    (de.comp.lang.java)
  • Re: Confused about ant api
    ... > I'm a bit confused about using the ant api. ... and the target that it must operate. ... > Very confusing. ...
    (comp.lang.java.programmer)