ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roos Tomas" <>
Subject RE: Fixed default target
Date Wed, 15 Dec 2010 13:36:12 GMT
I did this now according to Davids recommendation.
This seem to be an ok workaround, though we are almost there, there is
one thing missing.

<project xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:antcontrib="antlib:net.sf.antcontrib" basedir="." name="modules">
	<property name="build-infrastructure.dir" value="build" />
	<property file="" />
file="${build-infrastructure.dir}/branch-build-common.xml" />

	<target name="-delegate">
list="${ant.project.invoked-targets}" param="target">
						<target name="@{target}"

	<target name="publish" depends="-delegate" />

	<target name="integration" depends="-delegate" />
	<target name="milestone" depends="-delegate" />
	<target name="final" depends="-delegate" />

	<target name="local" depends="-delegate" />	
	<target name="shared" depends="-delegate" />

That's how it works at the moment.

As you can see in the -delegate method, it try to get every target as a
single target name,
I want this to become

<target name="target1" />
<target name="target2" />
<target name="target3" />

Instead, targets (which is an element)
	<macrodef name="run-module-builds">
		<element name="targets" />...

And since <targets> doesn't accept antcontrb:for as an element. I Wonder
how to group this to a <targets> tag which I can include in the 

<element name"targets" />
<antcontrib:for list="${ant.project.invoked-targets}" param="target">
//Append this target to the element on the targets element with <target
name="@{target}" />

<targets />

Any ideas?

Thanks everyone for the help so far!
-----Original Message-----
From: David Weintraub [] 
Sent: den 14 december 2010 14:45
To: Ant Users List
Subject: Re: Fixed default target

On Tue, Dec 14, 2010 at 3:47 AM, Roos Tomas
<> wrote:
> I'm wondering if it's possible to have a fixed default target, which 
> always executes instead of what's put on the command-line?
> The reason for this is we use the depends feature of ant to be able to

> for instance publish to an ivy repository with a better flow. ant 
> local milestone publish.

You could start all of the other target names with dashes. This makes
them impossible to execute on the command line. It's a common tactic to
make internal targets start with a dash for this reason.

If this is for initialization purposes, you can have non-targeted tasks
at the beginning of your Ant build.xml file. All of those tasks will be
executed no matter what target is selected. Unfortunately, you can't use
the "Ant" or "Antcall" task in this section. These will only be executed
if they're inside of an Ant target. Otherwise, you could put these as
part of the preliminary stuff and prevent people from executing other
tasks directly.

If you need to hit a preliminary task, you can make all other tasks in
your Antfile depend upon that task.

This request is a bit "unusual" because you're basically preventing the
developer from using Ant to its fullest.

David Weintraub

To unsubscribe, e-mail: For additional
commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message