You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Roos Tomas <To...@mpsbroadband.com> on 2010/12/14 09:47:03 UTC

Fixed default target

Hey!

 

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.

 

And for the toplevel I want to by using the invoked-targets property
pass this on to the a subant. The thing is
${ant.project.invoked-targets} is not available before hitting the first
target.

So is there a way of always hitting the same target, event with targets
specified on the command line? 

I can't really see why the bug regarding ${ant.project.invoked-targets}
was implemented if this is not possible, since when you would anyway
need to create all these extra targets at the toplevel ?

 

Thanks in advance, hope you understood.

Best regards, Tomas

 


RE: Fixed default target

Posted by Roos Tomas <To...@mpsbroadband.com>.
Also forgot the notation for properties isn't that easy all the time ;-)

-----Original Message-----
From: Roos Tomas [mailto:Tomas.Roos@mpsbroadband.com] 
Sent: den 15 december 2010 09:59
To: Ant Users List; ltsao@talk21.com
Subject: RE: Fixed default target

Yeah i thought of that too, though it isn't that clear for users that
has been using ant earlier and got a list of targets.

But I guess that's the last out come.

Thanks!

-----Original Message-----
From: ltsao@talk21.com [mailto:ltsao@talk21.com]
Sent: den 15 december 2010 09:55
To: Ant Users List
Subject: Re: Fixed default target

How about treating 'target' as command parameter, then do recursive ant
call using param as target.
Sent from my BlackBerry(r) wireless device

-----Original Message-----
From: "Roos Tomas" <To...@mpsbroadband.com>
Date: Wed, 15 Dec 2010 09:48:31
To: Ant Users List<us...@ant.apache.org>
Reply-To: "Ant Users List" <us...@ant.apache.org>
Subject: RE: Fixed default target

Well the thing is we have a multi build file system and in the root i
just want to relay the targets that were chosen by the commandline down
to root\module\build.xml.

But the thing it is not possible to get the
${ant.project.invoked-targets} before entering a target, which you
mentioned. Therefore it isn't possible to invoke with subant in an
initializer.

So I guess there is no workaround for this ?

Tomas

-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com]
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
<To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Fixed default target

Posted by Roos Tomas <To...@mpsbroadband.com>.
Yeah i thought of that too, though it isn't that clear for users that
has been using ant earlier and got a list of targets.

But I guess that's the last out come.

Thanks!

-----Original Message-----
From: ltsao@talk21.com [mailto:ltsao@talk21.com] 
Sent: den 15 december 2010 09:55
To: Ant Users List
Subject: Re: Fixed default target

How about treating 'target' as command parameter, then do recursive ant
call using param as target.
Sent from my BlackBerry(r) wireless device

-----Original Message-----
From: "Roos Tomas" <To...@mpsbroadband.com>
Date: Wed, 15 Dec 2010 09:48:31
To: Ant Users List<us...@ant.apache.org>
Reply-To: "Ant Users List" <us...@ant.apache.org>
Subject: RE: Fixed default target

Well the thing is we have a multi build file system and in the root i
just want to relay the targets that were chosen by the commandline down
to root\module\build.xml.

But the thing it is not possible to get the
${ant.project.invoked-targets} before entering a target, which you
mentioned. Therefore it isn't possible to invoke with subant in an
initializer.

So I guess there is no workaround for this ?

Tomas

-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com]
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
<To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Fixed default target

Posted by lt...@talk21.com.
How about treating 'target' as command parameter, then do recursive ant call using param as target.
Sent from my BlackBerry® wireless device

-----Original Message-----
From: "Roos Tomas" <To...@mpsbroadband.com>
Date: Wed, 15 Dec 2010 09:48:31 
To: Ant Users List<us...@ant.apache.org>
Reply-To: "Ant Users List" <us...@ant.apache.org>
Subject: RE: Fixed default target

Well the thing is we have a multi build file system and in the root i
just want to relay the targets that were chosen by the commandline down
to root\module\build.xml.

But the thing it is not possible to get the
${ant.project.invoked-targets} before entering a target, which you
mentioned. Therefore it isn't possible to invoke with subant in an
initializer.

So I guess there is no workaround for this ?

Tomas

-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com] 
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
<To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Fixed default target

Posted by Roos Tomas <To...@mpsbroadband.com>.
Well the thing is we have a multi build file system and in the root i
just want to relay the targets that were chosen by the commandline down
to root\module\build.xml.

But the thing it is not possible to get the
${ant.project.invoked-targets} before entering a target, which you
mentioned. Therefore it isn't possible to invoke with subant in an
initializer.

So I guess there is no workaround for this ?

Tomas

-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com] 
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
<To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Fixed default target

Posted by Roos Tomas <To...@mpsbroadband.com>.
No suggestions ? I'm realy stuck with this.

Tomas

> -----Original Message-----
> From: Roos Tomas [mailto:Tomas.Roos@mpsbroadband.com]
> Sent: den 15 december 2010 14:36
> To: Ant Users List
> Subject: RE: Fixed default target
> 
> 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="branch.properties" />
> 	<import
> file="${build-infrastructure.dir}/branch-build-common.xml" />
> 
> 	<target name="-delegate">
> 		<run-module-builds>
> 			<targets>
> 				<antcontrib:for
> list="${ant.project.invoked-targets}" param="target">
> 
> 	<sequential>
> 
> 	<target name="@{target}"
> />
> 
> 	</sequential>
> 				</antcontrib:for>
> 
> 			</targets>
> 		</run-module-builds>
> 	</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" /> </project>
> 
> 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
> 
> <targets>
> <target name="target1" />
> <target name="target2" />
> <target name="target3" />
> </targets>
> 
> 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">
> 
> <sequential>
> //Append this target to the element on the targets element with
<target
> name="@{target}" /> </sequential>
> </antcontrib:for>
> 
> <run-module-builds>
> <targets />
> </run-module-builds>
> 
> Any ideas?
> 
> Thanks everyone for the help so far!
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Fixed default target

Posted by Roos Tomas <To...@mpsbroadband.com>.
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="branch.properties" />
	<import
file="${build-infrastructure.dir}/branch-build-common.xml" />

	<target name="-delegate">
		<run-module-builds>
			<targets>
				<antcontrib:for
list="${ant.project.invoked-targets}" param="target">
					<sequential>
						<target name="@{target}"
/>
					</sequential>
				</antcontrib:for>	
			</targets>	
		</run-module-builds>	
	</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" />
</project>

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

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

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">
	
<sequential>
//Append this target to the element on the targets element with <target
name="@{target}" />
</sequential>
</antcontrib:for>	

<run-module-builds>
<targets />
</run-module-builds>

Any ideas?

Thanks everyone for the help so far!
 
-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com] 
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
<To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Fixed default target

Posted by David Weintraub <qa...@gmail.com>.
On Tue, Dec 14, 2010 at 3:47 AM, Roos Tomas <To...@mpsbroadband.com> 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
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org