Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / November 2003

Tip: Looking for answers? Try searching our database.

Ant: How to parameterize similar targets?

Thread view: 
Ronald Fischer - 26 Nov 2003 14:45 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.

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.