You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Clifton C. Craig" <cc...@icsaward.com> on 2004/01/09 16:34:09 UTC

Re: Mysterious SubAnt behaviour [possible SubAnt bug?]

I'm still having trouble with this mysterious behavior with the new 
SubAnt task. I have a temporary work-around involving a windows batch 
file but it is not ideal. I'd like to be able to call my build from 
within an automated process written in Ant and have it behave the same 
as it does from the command-line. Should this be submitted as a bug or 
am I doing something wrong. I've tried every different incarnation I can 
think of for achieving the desired behavior but nothing works.

-------- Original Message --------
Subject: 	Re: Including files in a dirset - mysterious SubAnt behavior
Date: 	Fri, 02 Jan 2004 15:45:06 -0500
From: 	Clifton C. Craig <cc...@icsaward.com>
Reply-To: 	Ant Users List <us...@ant.apache.org>
To: 	Ant Users List <us...@ant.apache.org>
References: 	<3F...@icsaward.com>



Ok this is spooky. I have a build that calls several builds in it's sub 
directories via SubAnt. The sub-builds should run with their basedir set 
to the folder they are located in. If I call the main build directly 
from the command line all is fine. However, if I call the main build 
from another build (as part of an automated process) then all of the 
main build's sub build's basedirs are set to the basedir of the main 
build. I thought that using a dirset would rectify the problem but it 
doesn't. Can anyone help me figure out why the strange behaviour? A 
simplified example is as such:

automated-build.xml:
   <!-- this build is located in the ${project.base}/tools/scripts dir
   <target name="clean-build" depends="init">
       <ant dir="${project.base}" antfile="main-build.xml" target="default"
           output="${log.dir}\nightly-build.log"/>
   </target>

main-build.xml:
   <!-- this build is located in the ${project.base} dir defined 
elsewhere...
   <target name="default" depends="init">
       <subant inheritall="false" inheritrefs="true"
           failonerror="${fail.on.error}">
            <!-- ${project.src} is the src folder under ${project.base} 
or ${project.base}/src -->
           <dirset dir="${project.src}" includes="/**">
               <!-- includes.selector is a custom selector that 
includes only folders that contain build.xml -->
               <selector refid="includes.selector"/>
           </dirset>
           <propertyset>
               <propertyref regex=".*"/>
           </propertyset>
       </subant>
   </target>

If I run main-build.xml from the command-line all build.xmls selected by 
subant run with their basedir set to their contained folder. However, 
when I run automated-build.xml all of the build.xmls under 
${project.src} run with their basedir set to ${project.base} which is 
the basedir of main-build.xml. (This, of course causes them to crash 
since they all use paths relative to their basedir.) What's the deal?



Earlier I wrote:

> How does a dirset act when one of its patternsets includes a file?  
> What I'm looking for is a way to include all sub-directories of a 
> given directory that contain build.xml so I can pass it off to SubAnt. 
> I was originally using a fileset but it caused a tricky error where 
> the basedir of the build file was being set to the basedir of the 
> calling target. I want the basedir of the build xmls to be set to the 
> folder they are found in. I was thinking that I could change my 
> fileset to a dirset which should implicitly set the basedir of all 
> located build xmls to the folder they located in. However I don't see 
> a straight foward way to do this with a dirset. I have a custom 
> selector that I could use but I was wondering if there was a pattern 
> expression that would be work as well. For example, if I use <include 
> name="**/build..xml"> in a dirset would this give me a set of all sub 
> folders that have build.xml or would it give me an error or what?
>
> Cliff
>
> Clifton C. Craig, Software Engineer
> Intelligent Computer Systems -  A Division of GBG
> 2101 Embassy Drive
> Lancaster, PA  17603
>
> Phone:  717-295-7977 ext. 621
> Fax:  717-295-7683
> ccc@icsaward.com
> ccraig@globalbeveragegroup.com
>
> **************************************************************************** 
>
> Mark the dates: February 22-25, 2004 at the Aladdin Hotel & Casino in Las
> Vegas, NV.
> GBG is pleased to announce the premier event for sales and distribution
> software solutions for soft drink, beer, water, snack, candy & tobacco
> organizations - Encounter 2004: GBG's 2nd Annual User Conference!
> Register by December 15th and receive early bird rates:
> http://www.globalbeveragegroup.com/postings/user_conf_2004_announcement.htm 
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>
> Clifton C. Craig, Software Engineer
> Intelligent Computer Systems -  A Division of GBG
> 2101 Embassy Drive
> Lancaster, PA  17603
>
> Phone:  717-295-7977 ext. 621
> Fax:  717-295-7683
> ccc@icsaward.com
> ccraig@globalbeveragegroup.com
>
> ****************************************************************************
> Mark the dates: February 22-25, 2004 at the Aladdin Hotel & Casino in Las
> Vegas, NV.
> GBG is pleased to announce the premier event for sales and distribution
> software solutions for soft drink, beer, water, snack, candy & tobacco
> organizations - Encounter 2004: GBG's 2nd Annual User Conference!
> Register by December 15th and receive early bird rates:
> http://www.globalbeveragegroup.com/postings/user_conf_2004_announcement.htm
>

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





-- 
Clifton C. Craig, Software Engineer
Intelligent Computer Systems -  A Division of GBG
2101 Embassy Drive
Lancaster, PA  17603

Phone:  717-295-7977 ext. 621
Fax:  717-295-7683
ccc@icsaward.com
ccraig@globalbeveragegroup.com
****************************************************************************


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


Re: Mysterious SubAnt behaviour [possible SubAnt bug?]

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 09 Jan 2004, Clifton C. Craig <cc...@icsaward.com> wrote:

> I'm still having trouble with this mysterious behavior with the new
> SubAnt task.

I must have missed the original mail, sorry.

> automated-build.xml:

>    <ant dir="${project.base}" antfile="main-build.xml" target="default"
>    output="${log.dir}\nightly-build.log"/>

> However, when I run automated-build.xml all of the build.xmls under
> ${project.src} run with their basedir set to ${project.base} which
> is the basedir of main-build.xml.

But the reason they do is not that it is the basedir of main-build.xml
- it is because you've use <ant>'s dir attribute.  See the table
"Basedir of the new project" in the manual for the Ant task, with dir
you fix the basedir of the build you invoke (and as a side effect of
all subbuilds of it).

Try

<ant antfile="${project.base}/main-build.xml" target="default"
     output="${log.dir}\nightly-build.log" inheritall="false"/>

instead.

Stefan

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