ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bhatia Saurabh \(CHA\)" <saurabh.bha...@etat.ge.ch>
Subject RE: Recovering the return code from the called build.xml into the calling build.xml
Date Wed, 30 Nov 2005 15:16:57 GMT
Bonjour/Hello/Gutentag, 

Exec doesnt work under windows NT with vmlauncher="false" but no problem on XP. Any clues
folks?

------------------------------------------------------------
This is how I call the target in my calling build.xml

<macrodef name="test-exec">
      		<attribute name="module-1"/>		
        	<sequential>
        	<echo message="Test du module @{module-1} (lancement target run-test)" />
        	<trycatch>
 		<try>
    			<antfetch dir="${revue.dir}/@{module-1}" target="run-test" return="run-test.result"/>
   			
    			<if>
 				<equals arg1="0" arg2="${run-test.result}" />
 			<then>
   				<echo message="The test completed successfully with code: ${run-test.result}" />
 			</then>
 			<else>
   				<echo message="The test completed with an error code: ${run-test.result}" />
 			</else>
			</if>
  		</try>
  		<catch>
    			<echo>There was an Exception</echo>
  		</catch>
  		<finally>
    			<echo>I continue executing tasks ...</echo>
  		</finally>
		</trycatch>
		</sequential>
        </macrodef>

-------------------------------------------------------------
This is the target defined in called build.xml

<target name="run-test" description="lancement du test unitaire">
   <echo message="lancement du test unitaire EvenementMetier..." />
   <exec dir="J:/RefonteAFC/Proto1.4/EvenementMetier/testunitaire" 
         executable="TestUnitaire_auto.bat" resolveexecutable="true" output="dir.txt" resultproperty="run-test.result"
		   failonerror="false" vmlauncher="false">
   </exec>
  </target> 

Windows XP:--------------------------------------------------

[echo] lancement du test unitaire EvenementMetier...
     [exec] Current OS is Windows XP
     [exec] Output redirected to D:\net\admin\revuecode_preprod\results\20051129\evm\EvenementMetier\dir.txt
     [exec] Executing 'J:\RefonteAFC\Proto1.4\EvenementMetier\testunitaire\TestUnitaire_auto.bat'
with 
     [echo] The test completed successfully with code: 0

Windows NT:-------------------------------------------------

[echo] lancement du test unitaire EvenementMetier...
     [echo] There was an Exception
     [echo] I continue executing tasks ...

Thanks in advance
Saurabh

-----Message d'origine-----
De : Bhatia Saurabh (CHA) [mailto:saurabh.bhatia@etat.ge.ch] 
Envoyé : vendredi, 25. novembre 2005 14:41
À : Ant Users List
Cc : antoine@gmx.de
Objet : RE: Recovering the return code from the called build.xml into the calling build.xml

Hi Klaus,
The code segment you submitted didnt work, I had already tried it. In fact, I got it working
like this...

			<antfetch dir="${revue.dir}/@{module-1}" target="run-test" return="run-test.result"/>
   			
    			<if>
 				<equals arg1="0" arg2="${run-test.result}" />
 			<then>
   				<echo message="The test completed successfully with code ${run-test.result}" />
 			</then>
 			<else>
   				<echo message="The test completed with an error code ${run-test.result}" />
 			</else> 

Antfetch is exactly what I was looking for...Thanks to you all !! 
Saurabh

-----Message d'origine-----
De : Allwicher, Klaus [mailto:Klaus.Allwicher@nuance.com] 
Envoyé : vendredi, 25. novembre 2005 12:51
À : Ant Users List
Cc : antoine@gmx.de
Objet : RE: Recovering the return code from the called build.xml into the calling build.xml

Maybe, I don't understand the problem right, but why don't you assign the
return code to another property ??

E.g.  
<macrodef name="test-exec">
	<attribute name="module-1"/>		
	<attribute name="return"/>		
<sequential>
	<echo message="Test du module @{module-1} (lancement target
run-test)" />         		
	<ant dir="${revue.dir}/@{module-1}" target="run-test"/>
	<antcallback return="run-test.result"/>  
	<echo message="Status of task run-test is ${run-test.result}" />    
	<var name="@{return}" value="${run-test.result}" />    
</sequential>
</macrodef>

> -----Original Message-----
> From: Bhatia Saurabh (CHA) [mailto:saurabh.bhatia@etat.ge.ch] 
> Sent: 25 November, 2005 11:42
> To: Ant Users List
> Cc: antoine@gmx.de; Bhatia Saurabh (CHA)
> Subject: RE: Recovering the return code from the called 
> build.xml into the calling build.xml
> 
> Hello Antoine,
> After all my tests on this taskdef, I found that an 
> antcallback works in the scope of 1 single build.xml file 
> ONLY. If my 1st build.xml file makes a call to a target in 
> another build.xml which in turn does an exec on the host 
> system, I have no way of recovering the 
> resultproperty="my.property" in the first build.xml.
> 
> Example:
> Caller code -------------------------------- build1.xml
> 	
> 	  <macrodef name="test-exec">
>       		<attribute name="module-1"/>		
>       		<sequential>
>          		<echo message="Test du module 
> @{module-1} (lancement target run-test)" />         		
>          		
>          		<ant dir="${revue.dir}/@{module-1}" 
> target="run-test"/>
>          		<!--
>          		<antcallback return="run-test.result"/>  
>          		-->
>          		<echo message="Status of task run-test 
> is ${run-test.result}" />         		
>         	</sequential>
>         </macrodef>
> Called code................................. build2.xml
> 
> <target name="run-test" description="lancement du test unitaire">
>    <echo message="lancement du test unitaire EvenementMetier!!" />
>    <exec dir="J:/RefonteAFC/Proto1.4/EvenementMetier/testunitaire" 
>          executable="TestUnitaire_auto.bat" 
> resolveexecutable="true" output="dir.txt" 
> resultproperty="run-test.result" 		   
> failonerror="false" vmlauncher="true">
>    </exec>
>   </target>
> 
> Thanks a lot for the pointers anyway... I hope I do find a 
> solution to this really....Its like saying that a Java object 
> can recover the return value only if the called method is 
> defined in the same object.
> 
> Saurabh
> 
> 
> 
> -----Message d'origine-----
> De : Antoine Levy-Lambert [mailto:antoine@gmx.de] Envoyé : 
> jeudi, 24. novembre 2005 22:09 À : Ant Users List Objet : Re: 
> Recovering the return code from the called build.xml into the 
> calling build.xml
> 
> Hello Saurabh,
> look at using ant-contrib.
> http://ant-contrib.sourceforge.net/tasks/tasks/antcallback_task.html
> Cheers,
> Antoine
> > --- Ursprüngliche Nachricht ---
> > Von: "Bhatia Saurabh \(CHA\)" <saurabh.bhatia@etat.ge.ch>
> > An: <user@ant.apache.org>
> > Betreff: Recovering the return code from the called 
> build.xml into the 
> > calling build.xml
> > Datum: Thu, 24 Nov 2005 10:49:44 +0100
> > 
> > Dear Community,
> > 
> > My calling build.xml makes a call to a target defined in a 
> different 
> > build.xml and this target does an exec. I do get the return 
> value from 
> > this exec in the called build.xml but I am looking for a 
> solution for 
> > recovering this resultproperty="run-test.result" in the 
> calling code 
> > so that I can invoke other targets in my calling build.xml based on 
> > the return code I got from the called build.xml. (e.g I 
> would like to 
> > send an email with success notification if the return code = 0 or a 
> > failure email notification if the return code is anything but 0).
> > 
> > Really appreciate your solutions and thanking in advance.
> > 
> > Saurabh
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
> additional commands, e-mail: user-help@ant.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
> additional commands, e-mail: user-help@ant.apache.org
> 

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


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


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


Mime
View raw message