You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David Adams <DA...@ignitesports.com> on 2002/08/27 17:31:30 UTC

using property in target depends

Hi,
I was looking to control a project flow by putting in a property value dynamically into the depends attribute of the target tag. 

For example, I wanted to do the following:
	<target name="main" depends="${build.type}"/>

	<target name="dev" depends="prepare,compile,dist,javadocs,test.suite"/>

	<target name="test" depends="prepare,compile,test.suite"/>

	<target name="prod" depends="prepare,compile,test.suite,dist,javadocs"/>

where build.type would be either dev, test, or prod, defaulting to dev in a properties file and configurable through the command line. 

I run into a problem with this, but it is not clear to me what the issue is. When running, I receive:
Target `${build.type}' does not exist in this project. It is used from target `main'.

I feel that I am missing something fundamental here....

Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Adams
Ignite Sports (www.ignitesports.com)
Voice: 773.293.4300
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Re: using property in target depends

Posted by Matt Benson <gu...@yahoo.com>.
Hmm, good point.

-Matt

--- Diane Holt <ho...@yahoo.com> wrote:
> --- David Adams <DA...@ignitesports.com> wrote:
> > I was looking to control a project flow by putting
> in a property value
> > dynamically into the depends attribute of the
> target tag. 
> > 
> > For example, I wanted to do the following:
> > 	<target name="main" depends="${build.type}"/>
> > 
> > 	<target name="dev"
> depends="prepare,compile,dist,javadocs,test.suite"/>
> > 
> > 	<target name="test"
> depends="prepare,compile,test.suite"/>
> > 
> > 	<target name="prod"
> >
> depends="prepare,compile,test.suite,dist,javadocs"/>
> > 
> > where build.type would be either dev, test, or
> prod, defaulting to dev
> > in a properties file and configurable through the
> command line. 
> 
> Dump "main" and just have "dev" be the default
> target. Anyone wanting to
> run one of the other targets instead should just run
> 'ant test' or 'ant
> prod' -- much easier than running 'ant
> -Dbuild.type=test' (besides which,
> it'll actually work :)
> 
> Diane
> 
> =====
> (holtdl@yahoo.com)
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: using property in target depends

Posted by Diane Holt <ho...@yahoo.com>.
--- David Adams <DA...@ignitesports.com> wrote:
> I was looking to control a project flow by putting in a property value
> dynamically into the depends attribute of the target tag. 
> 
> For example, I wanted to do the following:
> 	<target name="main" depends="${build.type}"/>
> 
> 	<target name="dev" depends="prepare,compile,dist,javadocs,test.suite"/>
> 
> 	<target name="test" depends="prepare,compile,test.suite"/>
> 
> 	<target name="prod"
> depends="prepare,compile,test.suite,dist,javadocs"/>
> 
> where build.type would be either dev, test, or prod, defaulting to dev
> in a properties file and configurable through the command line. 

Dump "main" and just have "dev" be the default target. Anyone wanting to
run one of the other targets instead should just run 'ant test' or 'ant
prod' -- much easier than running 'ant -Dbuild.type=test' (besides which,
it'll actually work :)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: using property in target depends

Posted by Matt Benson <gu...@yahoo.com>.
Or you could do it like this:

<target name="main" depends="init,dev,test,prod" />

<target name="init">
  <condition property="dev">
    <equals trim="true"
     arg1="${build.type}" arg2="dev" />
  </condition>
  <condition property="test">
    <equals trim="true"
     arg1="${build.type}" arg2="test" />
  </condition>
  <condition property="prod">
    <equals trim="true"
     arg1="${build.type}" arg2="prod" />
  </condition>
</target>

<target name="dev" if="dev">
...
</target>

<target name="test" if="test">
...
</target>

<target name="prod" if="prod">
...
</target>

But this is a little longer...  :)

-Matt


--- Matt Benson <gu...@yahoo.com> wrote:
> It does look like it would be nice to do what you
> want
> in this way.  Apparently target names such as in a
> depends attribute are not evaluated in this way. 
> You
> can do what you are trying to do another way, using
> the <antcall> task.
> 
> -Matt
> 
> --- David Adams <DA...@ignitesports.com> wrote:
> > Hi,
> > I was looking to control a project flow by putting
> > in a property value dynamically into the depends
> > attribute of the target tag. 
> > 
> > For example, I wanted to do the following:
> > 	<target name="main" depends="${build.type}"/>
> > 
> > 	<target name="dev"
> >
> depends="prepare,compile,dist,javadocs,test.suite"/>
> > 
> > 	<target name="test"
> > depends="prepare,compile,test.suite"/>
> > 
> > 	<target name="prod"
> >
> depends="prepare,compile,test.suite,dist,javadocs"/>
> > 
> > where build.type would be either dev, test, or
> prod,
> > defaulting to dev in a properties file and
> > configurable through the command line. 
> > 
> > I run into a problem with this, but it is not
> clear
> > to me what the issue is. When running, I receive:
> > Target `${build.type}' does not exist in this
> > project. It is used from target `main'.
> > 
> > I feel that I am missing something fundamental
> > here....
> > 
> > Thanks.
> > 
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > David Adams
> > Ignite Sports (www.ignitesports.com)
> > Voice: 773.293.4300
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > 
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: using property in target depends

Posted by Matt Benson <gu...@yahoo.com>.
It does look like it would be nice to do what you want
in this way.  Apparently target names such as in a
depends attribute are not evaluated in this way.  You
can do what you are trying to do another way, using
the <antcall> task.

-Matt

--- David Adams <DA...@ignitesports.com> wrote:
> Hi,
> I was looking to control a project flow by putting
> in a property value dynamically into the depends
> attribute of the target tag. 
> 
> For example, I wanted to do the following:
> 	<target name="main" depends="${build.type}"/>
> 
> 	<target name="dev"
> depends="prepare,compile,dist,javadocs,test.suite"/>
> 
> 	<target name="test"
> depends="prepare,compile,test.suite"/>
> 
> 	<target name="prod"
> depends="prepare,compile,test.suite,dist,javadocs"/>
> 
> where build.type would be either dev, test, or prod,
> defaulting to dev in a properties file and
> configurable through the command line. 
> 
> I run into a problem with this, but it is not clear
> to me what the issue is. When running, I receive:
> Target `${build.type}' does not exist in this
> project. It is used from target `main'.
> 
> I feel that I am missing something fundamental
> here....
> 
> Thanks.
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> David Adams
> Ignite Sports (www.ignitesports.com)
> Voice: 773.293.4300
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>