ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tye, Tim" <t...@firstam.com>
Subject RE: Patch to override targets
Date Thu, 14 Nov 2002 19:04:54 GMT
I'll explain what we modified in ant first and if you are interested you can
read the situation that motivated the change.  Sorry this is so long.

Target:
	boolean overriding attribute - set in build.xml file
	boolean completed attribute - set to true after target was executed

Project:
	Skips completed targets

Ant Task:
	Copies overidding targets in current project to subproject target
list.

Essentially this is target overriding.  It works, but others with more
experience with ant than I may have different takes on the need/implentation
of this functionality.


Motivation:

The problem that we faced with ant was related to the way our project and
source control is organized:

We use cvs to store our java projects
Each java library or java program is it's own project in cvs
Each java library or program is independently buildable
Each java library or program is independently versioned

We use standardized target names in build.xml.  For instace the project
com.company.mylib1 has targets:

	<target name="com.company.mylib1.init" >
	<target name="com.company.mylib1.compile" >
	<target name="com.company.mylib1.jar" >

Building a lib with no dependencies other than standard java libs is no
different than any other ant build
Building a program or lib with a dependecy on another internal lib is where
the fun starts.

First ant is run on the superproject
The superproject uses the cvs task to checkout or update the desired
subproject
The superproject runs ant task on the build.xml of the subproject

The real fun starts when subprojects themselves have subprojects
The insanity starts when two projects/subprojects need the same subproject.
This is not at all rare since most of our projects and libs want to include
our util package.  We have one project that has five levels of subprojects.

The ideal solution would be to only extract (cvs) and compile a given
subproject once.  But since each project in independently buildable, they
all want to go get their subprojects from cvs.  This is where we need target
overriding.

We define the standard targets in the superproject:

	<target name="com.company.mylib1.extract" overriding="true" >
	<target name="com.company.mylib1.build" overriding="true" >

to retrieve from cvs and run the ant task on a particular subproject.  You
might notice a new attribute.  This tells the ant task to copy this target
to the target list of the subproject.  This may or may not replace an
existing target but will be propagated all the way down the subproject tree.
We also added the ability to mark a target as completed.  When the project
is being built, completed targets are skipped.  Therefore subprojects
needing the same subproject will skip those steps.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message