Marius Kjeldahl wrote:
I'm pretty new to nant and have a question with regards to what I
consider the equivalent of a top-level makefile that descends down
into each subdirectory and builds the given target based on input to
the top-level build file.
...
If I type "nant" in a top level directory structure with a nant
project in each subdir, this works fine. What I would like however is
to be able to type "nant sometarget" and have the top-level nant file
carry this target over to the subdirs.
For instance "nant clean". It can easily be supported by duplicating
the "<target name=" part of the file with name="clean". But then I
would need a target section for each possible target, and this seems a
bit redundant.
In order to type "nant sometarget", there must be an explicit target by
that name in the top level build file (or in a build file it includes
with <include>, which is not the same as executing it with <nant>). You
could paramaterize the target in your example that calls the subtargets
by changing the <nant> task to:
<nant target=${theTarget} ...,
renaming that target to
<target name="doSubbuild ...
and then adding targets of the form:
<target name="build">
<property name="theTarget" value="build" />
<call target="doSubbuild" />
</target>
This has the advantage of only needing one copy of the <nant> task
invocation, and all that it involves. So it removes much of the
redundancy, but not all. It has the disadvantage of not exploiting
dependency analysis in the subbuilds if you want to do multiple targets,
but so does your method.
I think a better solution is to use a property definition instead of a
target parameter on the command line. In other words, instead of typing
nant someTarget
at the command line, you'd type
nant -D:theTarget=someTarget
This way, you could eliminate all of the explicit targets, and hence all
of the redundancy. But it has one more advantage, in that you could
pass multiple targets to the subbuilds. So you could type, for example,
nant -D:theTarget="build test"
By doing it this way, you'd only have one invocation of NAnt per
subbuild, and you wouldn't need to worry about whether or not the test
target depends on the build target. With your approach and my first
approach, you'd have one subbuild call of the form <nant target="build"
...> and a second, in the same subdirectory, of the form <nant
target="test" ...> If test depended on build, you'd wind up running the
build target twice. With my second approach, you'd only have one
invocation of the form <nant target="build test" ...>, and the right
thing would happen.
Gary
Gary
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users