You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Khehra, Sukh" <Su...@wsj.com> on 2004/07/30 01:47:28 UTC

parallel ant calls not working?! help please.

Hi,

is it not true that the law of "properties not being mutable" can be circumvented by using "antcall"s? if yes, how do i explain this? this works fine if i don't try to make the antcalls in parallel.

*************************
my build.xml is

<project name="test2" default="qa-rails">

<taskdef resource="net/sf/antcontrib/antlib.xml"/>

<target name="qa-rails">

<for param="file" parallel="true">
  <path>
    <fileset dir="properties/qa/rails" excludes="common.properties"/>
  </path>
  <sequential>
    <echo message="@{file}"/>
    <propertyregex override="yes"
      property="program"  input="@{file}"
      regexp=".*[/\\]([^\.]*)\.properties" replace="\1"/>
      <antcall target="tar">
         <param name="apache.properties" value="properties/qa/rails/${program}.properties"/>
         <param name="common.properties" value="properties/qa/rails/common.properties"/>
         <param name="targetdir" value="targets/qa"/>         
         <param name="environment" value="rails"/>
      </antcall>      
  </sequential>
</for>

</target>

<target name="tar">
   
   <property file="${apache.properties}"/>
   <property file="${common.properties}"/>   

   <echo message="*****"/>
   <echo message="properties from ${apache.properties},${deployment.name},${deployment.usersX},${deployment.usersX.ip},${deployment.online.ip}"/>   
   <echo message="*****"/>
   
</target>


</project>

*******************
my output is

C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf>ant -f test2.txt
Buildfile: test2.txt

qa-rails:
     [echo] C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf\properties\qa\rails\qaj2kweb01.properties
     [echo] C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf\properties\qa\rails\qaj2kweb05.properties
     [echo] C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf\properties\qa\rails\qaj2kweb04.properties
     [echo] C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf\properties\qa\rails\qaj2kweb03.properties
     [echo] C:\Documents and Settings\KhehraS\My Documents\barrons\apache-conf\properties\qa\rails\qaj2kweb02.properties

tar:

tar:
     [echo] *****
     [echo] properties from properties/qa/rails/qaj2kweb01.properties,qaj2kweb01,users1,192.168.141.51,192.168.141.39

tar:
     [echo] *****

tar:
     [echo] *****
     [echo] properties from properties/qa/rails/qaj2kweb05.properties,qaj2kweb05,users4,192.168.141.56,192.168.141.55
     [echo] *****
     [echo] *****
     [echo] *****
     [echo] properties from properties/qa/rails/qaj2kweb02.properties,qaj2kweb02,users1,192.168.141.52,192.168.141.40
     [echo] *****

tar:
     [echo] properties from properties/qa/rails/qaj2kweb04.properties,qaj2kweb04,users3,192.168.141.54,192.168.141.50
     [echo] *****
     [echo] *****
     [echo] properties from properties/qa/rails/qaj2kweb02.properties,qaj2kweb02,users1,192.168.141.52,192.168.141.40
     [echo] *****

BUILD SUCCESSFUL
Total time: 1 second

**********************************************

Note how i got the following twice and missed "qaj2kweb03". and this weird behavior changes every run. I could really use some help from you ant gurus out there.

     [echo] properties from properties/qa/rails/qaj2kweb02.properties,qaj2kweb02,users1,192.168.141.52,192.168.141.40

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


Re: parallel ant calls not working?! help please.

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Khehra, Sukh wrote:
> Hi,
> 
> is it not true that the law of "properties not being mutable" can be circumvented by using "antcall"s? 

It can seem to have that effect but it is not *strictly* true. Each 
antcall runs in its own "context" and therefore properties set within 
that context do not affect a property of the same name in a different 
context. For the purposes of your usage, however, the distinction is not 
important.

> if yes, how do i explain this? this works fine if i don't try to make the antcalls in parallel.
> 
> *************************
> my build.xml is
> 
> <project name="test2" default="qa-rails">
> 
> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> 
> <target name="qa-rails">
> 
> <for param="file" parallel="true">
>   <path>
>     <fileset dir="properties/qa/rails" excludes="common.properties"/>
>   </path>
>   <sequential>
>     <echo message="@{file}"/>
>     <propertyregex override="yes"
>       property="program"  input="@{file}"
>       regexp=".*[/\\]([^\.]*)\.properties" replace="\1"/>
>       <antcall target="tar">
>          <param name="apache.properties" value="properties/qa/rails/${program}.properties"/>
>          <param name="common.properties" value="properties/qa/rails/common.properties"/>
>          <param name="targetdir" value="targets/qa"/>         
>          <param name="environment" value="rails"/>
>       </antcall>      
>   </sequential>
> </for>
> 

My guess, and I don't have much experience with these particular tasks, 
is that you are coming unstuck in the setting of the "program" property. 
Since this is presumably being done in multiple threads, there is some 
sort of collision occurring on the setting of that value.

IOW, you really need to move the setting of "program" into the antcall'd 
context.

Conor

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