You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Greg Irvine <gr...@thalesatm.com> on 2006/06/15 08:07:49 UTC

"Recursiveness" / property already used in a "generic" build...

Hi all.

 

I'm trying to write a generic build file that uses a properties file to
inform the generic build file of which subprojects to build. 

 

So, the build.xml loads a build.properties which has a property buildorder
which is a list of subprojects in that directory to build, and this order is
specific due to dependencies.

 

I have this working just fine (generally).

 

This works if multiple folders have the same level do the same thing.  I'm
assuming this works because once the explicit call to build Folder1 returns,
any properties set in Folder1 or lower are cleared, so when Folder2 build
loads the build.properties the buildorder property set in Folder1 has been
cleared.

 

Parent -> Build.xml explicitly calls build on Folder1 and Folder2

          Folder1 -> build.xml + build.properties (buildorder=SubFolder1,
SubFolder2, SubFolder3)

                      -> SubFolder1

                      -> SubFolder2

                      -> SubFolder3

          Folder2-> build.xml + build.properties (buildorder=SubFolder1,
SubFolder2, SubFolder3)

                      -> SubFolder1

                      -> SubFolder2

                      -> SubFolder3

 

The problem I have is that if one of those projects is in fact a folder that
itself has a list of projects to build I find the property buildorder is
already set by the parent build file and fails trying to build the same
stuff again but in the subfolder.

          Folder1 -> build.xml + build.properties (buildorder=SubFolder1,
SubFolder2, SubFolder3)

                      -> SubFolder1 -> build.xml + build.properties
(buildorder=SubSubFolder1, SubSubFolder2, SubSubFolder3)

                                      -> SubSubFolder1

                                      -> SubSubFolder2

                                      -> SubSubFolder3

                      -> SubFolder2

                      -> SubFolder3

 

i.e. Folder1 build loads buildorder from build.properties and calls
build.xml in SubFolder1 (as specific in build.properties) which tries to
load it's build.properties which tries to define buildorder and of course
can't.

Hence, the build in SubFolder1 tries to build SubFolder1, SubFolder2,
SubFolder3 as defined by the parent buildorder again instead of the "new"
SubSubFolder1.

 

Any suggestions on how to get around this would be great.

 

Thanks and regards,

 

Greg.

 

Ps. If you REALLY think Maven is a better option let me know and I'll just
have to do an ROI analysis.


Re: "Recursiveness" / property already used in a "generic" build...

Posted by Dominique Devienne <dd...@gmail.com>.
> Just curious...how are you calling these sub project build.xml's from
> the parent?  Are you using <ant> task?  If so, probably want to do <ant
> inheritAll = "false".../>

Yes, it's a good point Scot.

I was using a different approach Greg. Instead of "parametring" the
generic build using a properties file, I was defining 2 generic
builds. One that does the work of building something (library.xml for
example, that would build one native lib using Ant-Contrib's <cc>),
and another called recurse.xml that defined dummy targets that simply
"forward" the targets to sub-builds, using <subant>.

In dirs where to recurse, I would define a build.xml that imports
recurse.xml and simply define the build <path>. Tiny, tiddy build.

In dirs where to build something, I'd do the work, usually just
defining a few things explicitly, like the "compile" target, and
inherit all other targets from the imported library.xml for example.

Recursing builds use <subant>, which defaults to inheritAll="false",
unlike <ant>. If I want to pass in a few explicit props, that's done
once and for all in recurse.xml (usually using a <propertyset>).

This setup emulates well enough the recursing nature of most
Makefile-based builds, and worked well for several large builds of
mine. You factor in the behavior in impored builds, and leave the
"parameterizing" data in the builds themselves.

This is my recommended approach to the recursing build idiom ;-) --DD

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


Re: "Recursiveness" / property already used in a "generic" build...

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Greg:

Just curious...how are you calling these sub project build.xml's from 
the parent?  Are you using <ant> task?  If so, probably want to do <ant 
inheritAll = "false".../>

Greg Irvine wrote:
> Hi all.
>
>  
>
> I'm trying to write a generic build file that uses a properties file to
> inform the generic build file of which subprojects to build. 
>
>  
>
> So, the build.xml loads a build.properties which has a property buildorder
> which is a list of subprojects in that directory to build, and this order is
> specific due to dependencies.
>
>  
>
> I have this working just fine (generally).
>
>  
>
> This works if multiple folders have the same level do the same thing.  I'm
> assuming this works because once the explicit call to build Folder1 returns,
> any properties set in Folder1 or lower are cleared, so when Folder2 build
> loads the build.properties the buildorder property set in Folder1 has been
> cleared.
>
>  
>
> Parent -> Build.xml explicitly calls build on Folder1 and Folder2
>
>           Folder1 -> build.xml + build.properties (buildorder=SubFolder1,
> SubFolder2, SubFolder3)
>
>                       -> SubFolder1
>
>                       -> SubFolder2
>
>                       -> SubFolder3
>
>           Folder2-> build.xml + build.properties (buildorder=SubFolder1,
> SubFolder2, SubFolder3)
>
>                       -> SubFolder1
>
>                       -> SubFolder2
>
>                       -> SubFolder3
>
>  
>
> The problem I have is that if one of those projects is in fact a folder that
> itself has a list of projects to build I find the property buildorder is
> already set by the parent build file and fails trying to build the same
> stuff again but in the subfolder.
>
>           Folder1 -> build.xml + build.properties (buildorder=SubFolder1,
> SubFolder2, SubFolder3)
>
>                       -> SubFolder1 -> build.xml + build.properties
> (buildorder=SubSubFolder1, SubSubFolder2, SubSubFolder3)
>
>                                       -> SubSubFolder1
>
>                                       -> SubSubFolder2
>
>                                       -> SubSubFolder3
>
>                       -> SubFolder2
>
>                       -> SubFolder3
>
>  
>
> i.e. Folder1 build loads buildorder from build.properties and calls
> build.xml in SubFolder1 (as specific in build.properties) which tries to
> load it's build.properties which tries to define buildorder and of course
> can't.
>
> Hence, the build in SubFolder1 tries to build SubFolder1, SubFolder2,
> SubFolder3 as defined by the parent buildorder again instead of the "new"
> SubSubFolder1.
>
>  
>
> Any suggestions on how to get around this would be great.
>
>  
>
> Thanks and regards,
>
>  
>
> Greg.
>
>  
>
> Ps. If you REALLY think Maven is a better option let me know and I'll just
> have to do an ROI analysis.
>
>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


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