You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mark Lundquist <ml...@comcast.net> on 2005/02/10 20:30:44 UTC
How to?: add target dependencies
Hi,
I've been using ant for some time, but I'm no expert. I just joined
this list. And here's my question! :-)
Actually, I can't even think how to phrase this question in any more
general terms :-)... so I'll just describe specifically what I'm trying
to accomplish (part of it will only make sense if you understand
Subversion, but oh well).
I've got several "modules" that I need to be able to build into various
projects. So what I think I'd like to be able to do is use <macrodef>
and then be able to just call out the modules like so:
<module name="killer-app" />
<module name="job-security" />
<module name="legacy-crap" />
<!-- etc... -->
The idea is that this would
(a) build up a file that I can use to invoke "svn propset svn:externals
-f", then "svn update" the external 'mount-point' if it doesn't exist
— i.e., "fetch" the module sources into the local project;
(b) create a task for each module (e.g., "modules:killer-app") that
calls <ant> in the module subdirectory and also does some other stuff;
(c) make it so that the task "module" invokes all the module targets.
I think I can handle all the ant machinery for (a) and (b); it's just
(c) that has me flummoxed.
This kind of thing is a way of life in 'make'... there, you don't even
think about it. You can say:
modules:; module.killer-app
modules:; module.legacy-crap
to successively add dependencies to a target. So you can do the same
thing in a macro ("modules:; this_module" or whatever). Or, you can
say
MODULES += this_module
or
MODULES = $(MODULES) this_module
(depending on the variant of make), and then later:
modules: $(MODULES)
So there are a couple of ways in make, but I haven't seen that it's
possible to add a dependency to an existing target. And Ant properties
are immutable, so I can't go that way...
BTW this isn't meant as an ant vs. make thing, I just mention it in the
hopes that maybe somebody else with a 'make' background will recognize
what the crap I'm talking about :-) :-).
Any suggestions?
—mark—
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Alan Gutierrez <al...@engrm.com>.
* Mark Lundquist <ml...@comcast.net> [2005-02-12 09:01]:
>
> Hey Alan, good to hear from you!
>
> On Feb 11, 2005, at 5:57 PM, Alan Gutierrez wrote:
>
> > Mark
> >
> > I'm now using XSLT to generate my Ant files. Any place where
> > there is iteration, or any sort of logic, XSLT makes it simple
> > and straghtforward.
> >
> > I know you work with XSLT, so I'm going to encourage you to
> > leverage those studies.
>
> D'oh! Why didn't I think of that...? I know ant has an XSLT task,
> I've seen how Cocoon uses it to generate the blocks build file file
> from gump.xml...
> > Let me know if you want to look at what I've been up to.
> Sure, I'd love to see what you've got going.
> The idea of using Groovy Markup w/ Ant is intriguing, too... could be
> the excuse I'm looking for to learn Groovy, but that's still more
> learning curve than I have bandwidth for right now. Maybe over summer
> :-)
Groovy Markup isn't as useful as XSLT.
I use XSLT to generate my build files. It's like running
configure, except it does a lot less work, since there are far
fewer platform issues.
I use XSLT 2.0, and Saxon 8.2, to generate JUnit tests.
I can give you a login to my repository and let you checkout a
project. Contact me off-list.
--
Alan Gutierrez - alan@engrm.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Alan Gutierrez <al...@engrm.com>.
* Mark Lundquist <ml...@comcast.net> [2005-02-12 09:01]:
>
> Hey Alan, good to hear from you!
>
> On Feb 11, 2005, at 5:57 PM, Alan Gutierrez wrote:
>
> > Mark
> >
> > I'm now using XSLT to generate my Ant files. Any place where
> > there is iteration, or any sort of logic, XSLT makes it simple
> > and straghtforward.
> >
> > I know you work with XSLT, so I'm going to encourage you to
> > leverage those studies.
> D'oh! Why didn't I think of that...? I know ant has an XSLT task,
> I've seen how Cocoon uses it to generate the blocks build file file
> from gump.xml...
> > Let me know if you want to look at what I've been up to.
> Sure, I'd love to see what you've got going.
> The idea of using Groovy Markup w/ Ant is intriguing, too... could be
> the excuse I'm looking for to learn Groovy, but that's still more
> learning curve than I have bandwidth for right now. Maybe over summer
> :-)
Groovy Markup isn't as useful as XSLT.
I use XSLT to generate my build files. It's like running
configure, except it does a lot less work, since there are far
fewer platform issues.
I use XSLT 2.0, and Saxon 8.2, to generate JUnit tests.
I can give you a login to my repository and let you checkout a
project. Contact me off-list.
--
Alan Gutierrez - alan@engrm.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Mark Lundquist <ml...@comcast.net>.
Hey Alan, good to hear from you!
On Feb 11, 2005, at 5:57 PM, Alan Gutierrez wrote:
> Mark
>
> I'm now using XSLT to generate my Ant files. Any place where
> there is iteration, or any sort of logic, XSLT makes it simple
> and straghtforward.
>
> I know you work with XSLT, so I'm going to encourage you to
> leverage those studies.
D'oh! Why didn't I think of that...? I know ant has an XSLT task,
I've seen how Cocoon uses it to generate the blocks build file file
from gump.xml...
> Let me know if you want to look at what I've been up to.
Sure, I'd love to see what you've got going.
The idea of using Groovy Markup w/ Ant is intriguing, too... could be
the excuse I'm looking for to learn Groovy, but that's still more
learning curve than I have bandwidth for right now. Maybe over summer
:-)
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Alan Gutierrez <al...@engrm.com>.
* Mark Lundquist <ml...@comcast.net> [2005-02-11 12:47]:
>
> On Feb 10, 2005, at 11:41 AM, Matt Benson wrote:
>
> >Looks like your main question is how to accumulate,
> >then iterate, over these modules.
>
> Pretty much, except for two things:
>
> 1) Stylistically, I'd prefer to that the iteration be implicit rather
> than explicit, i.e. a declarative style...
>
> 2) I'd like to have individual targets for the modules that I can run
> from the top level, e.g. "ant modules:module:foo".
>
> If I had those targets and could also somehow create
>
> <target name="modules:build-all" depends="modules:module:foo,
> modules:module:bar, modules:module:baz" />
>
> ...which is really what I had in mind for (1).
>
> But if I gotta use explicit iteration then so be it, see below...
Mark
I'm now using XSLT to generate my Ant files. Any place where
there is iteration, or any sort of logic, XSLT makes it simple
and straghtforward.
I know you work with XSLT, so I'm going to encourage you to
leverage those studies.
Let me know if you want to look at what I've been up to.
--
Alan Gutierrez - alan@engrm.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Mark Lundquist <ml...@comcast.net>.
On Feb 11, 2005, at 10:01 AM, Matt Benson wrote:
> I don't know what version of ant-contrib you are
> using, but later versions include the for task which
> is a hybrid of foreach and macrodef, whose chief
> benefit is that it avoids the incursion of an entirely
> new project context, unlike foreach. Translation:
> foreach will be slow and memory-hungry compared to
> for.
Ah, OK... I saw the <for> task, but kind of didn't understand what it
was <for> :-). Thanks! (I'm using the latest ant-contrib).
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Matt Benson <gu...@yahoo.com>.
--- Mark Lundquist <ml...@comcast.net> wrote:
> <target name="modules:build-all">
> <foreach
> list="${modules:modules}"
> target="modules.build-module"
> param="name"
> />
> </target>
I don't know what version of ant-contrib you are
using, but later versions include the for task which
is a hybrid of foreach and macrodef, whose chief
benefit is that it avoids the incursion of an entirely
new project context, unlike foreach. Translation:
foreach will be slow and memory-hungry compared to
for.
HTH,
Matt
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Mark Lundquist <ml...@comcast.net>.
On Feb 10, 2005, at 11:41 AM, Matt Benson wrote:
> Looks like your main question is how to accumulate,
> then iterate, over these modules.
Pretty much, except for two things:
1) Stylistically, I'd prefer to that the iteration be implicit rather
than explicit, i.e. a declarative style...
2) I'd like to have individual targets for the modules that I can run
from the top level, e.g. "ant modules:module:foo".
If I had those targets and could also somehow create
<target name="modules:build-all" depends="modules:module:foo,
modules:module:bar, modules:module:baz" />
...which is really what I had in mind for (1).
But if I gotta use explicit iteration then so be it, see below...
> It looks as though
> ant-contrib has some helpful tasks. You could set a
> new property for each of your modules: module.foo=foo
> or whatever. Then it appears you could use
> ant-contrib's propertyselector task with a select
> attribute value of "$${\0}" (you might have to
> experiment). This should get you a single property
> containing the property-expansion notation of all
> matching properties. You can then use this list as
> input to ant-contrib's for task, calling your macro
> for each module name.
OK, well I finally got the chance to open up this ant-contrib box...
:-) and here's what I came up with:
In build.xml:
<!-- Modules -->
<import file="modules.ant"/>
<property name="modules:module:foo" value="foo" />
<property name="modules:module:bar" value="bar" />
<target name="modules" depends="modules:build-all"/>
...then, in modules.ant:
<project name="modules">
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<target name="modules.build-module">
<echo message=":::::::::: building module: ${name} ::::::::::" />
<mkdir dir="webapp/modules" />
<exec dir="webapp/modules" executable="ln">
<arg line="-sfh ${basedir}/modules/${name}/mount ${name}" />
</exec>
<ant dir="modules/${name}" />
</target>
<propertyselector property="modules:modules"
match="modules:module:(.*)"
select="\1"
/>
<target name="modules:build-all">
<foreach
list="${modules:modules}"
target="modules.build-module"
param="name"
/>
</target>
</project>
I still need to add the Subversion stuff, then this will be 95% of what
I want, and the other 5% I can live without... :-)
Thanks for the suggestion!
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to?: add target dependencies
Posted by Matt Benson <gu...@yahoo.com>.
Looks like your main question is how to accumulate,
then iterate, over these modules. It looks as though
ant-contrib has some helpful tasks. You could set a
new property for each of your modules: module.foo=foo
or whatever. Then it appears you could use
ant-contrib's propertyselector task with a select
attribute value of "$${\0}" (you might have to
experiment). This should get you a single property
containing the property-expansion notation of all
matching properties. You can then use this list as
input to ant-contrib's for task, calling your macro
for each module name.
Maybe food for thought, anyway...
HTH,
Matt
--- Mark Lundquist <ml...@comcast.net> wrote:
> Hi,
>
> I've been using ant for some time, but I'm no
> expert. I just joined
> this list. And here's my question! :-)
>
> Actually, I can't even think how to phrase this
> question in any more
> general terms :-)... so I'll just describe
> specifically what I'm trying
> to accomplish (part of it will only make sense if
> you understand
> Subversion, but oh well).
>
> I've got several "modules" that I need to be able to
> build into various
> projects. So what I think I'd like to be able to do
> is use <macrodef>
> and then be able to just call out the modules like
> so:
>
> <module name="killer-app" />
> <module name="job-security" />
> <module name="legacy-crap" />
> <!-- etc... -->
>
> The idea is that this would
>
> (a) build up a file that I can use to invoke "svn
> propset svn:externals
> -f", then "svn update" the external 'mount-point' if
> it doesn't exist
> � i.e., "fetch" the module sources into the local
> project;
>
> (b) create a task for each module (e.g.,
> "modules:killer-app") that
> calls <ant> in the module subdirectory and also does
> some other stuff;
>
> (c) make it so that the task "module" invokes all
> the module targets.
>
> I think I can handle all the ant machinery for (a)
> and (b); it's just
> (c) that has me flummoxed.
>
> This kind of thing is a way of life in 'make'...
> there, you don't even
> think about it. You can say:
>
> modules:; module.killer-app
> modules:; module.legacy-crap
>
> to successively add dependencies to a target. So
> you can do the same
> thing in a macro ("modules:; this_module" or
> whatever). Or, you can
> say
>
> MODULES += this_module
>
> or
>
> MODULES = $(MODULES) this_module
>
> (depending on the variant of make), and then later:
>
> modules: $(MODULES)
>
> So there are a couple of ways in make, but I haven't
> seen that it's
> possible to add a dependency to an existing target.
> And Ant properties
> are immutable, so I can't go that way...
>
> BTW this isn't meant as an ant vs. make thing, I
> just mention it in the
> hopes that maybe somebody else with a 'make'
> background will recognize
> what the crap I'm talking about :-) :-).
>
> Any suggestions?
> �mark�
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org