You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eric Fetzer <el...@yahoo.com> on 2011/06/02 17:02:14 UTC
Do things based on project success or failure
I have to update a database one way or another based on project success or
failure. So I'm messing around with the <exec> task with errorproperty
attribute. I'm trying to make it so that failure will test one way vs. success
testing another. The best thing I can come up with is the following:
<----------------------------------------------------------------->
Build File 1:
<project name="test" default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="test">
<exec dir="." executable="cmd.exe" errorproperty="returncode">
<arg line="/c ant -f test2.xml -Dgood=${good}"/>
</exec>
<echo message="returncode is: ${returncode}"/>
<if>
<equals arg1="${returncode}" arg2="" />
<then>
<echo message="It succeeded"/>
</then>
<else>
<echo message="It failed"/>
</else>
</if>
</target>
</project>
Build File 2:
<project name="test2" default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="test">
<if>
<equals arg1="${good}" arg2="true" />
<then>
<echo message="Good!"/>
</then>
<else>
<echo message="Bad"/>
<fail/>
</else>
</if>
</target>
</project>
</----------------------------------------------------------------->
So if I pass >ant -f test.xml -Dgood="true"
I end up in the success code. Or if I pass >ant -f test.xml
-Dgood="anythingElse"
I end up in the failure code.
Does anyone have a more graceful way to do this?
Thanks,
Eric
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
Worked wonderfully, thanks!
On Jun 2, 2011, at 3:37 PM, Vimil Saju <vi...@yahoo.com> wrote:
> You could also use the trycatch task from antcontrib. the try task has a catch block that executes when any of the tasks within the try block fails.
>
> --- On Thu, 6/2/11, Eric Fetzer <el...@yahoo.com> wrote:
>
> From: Eric Fetzer <el...@yahoo.com>
> Subject: Re: Do things based on project success or failure
> To: "Ant Users List" <us...@ant.apache.org>
> Date: Thursday, June 2, 2011, 12:31 PM
>
> No problem Rob! The way I posted works great, I was just wondering if there was
> a more graceful way to do it. I think I can get the properties to pass as well
> with the echoproperties task... Thanks!
>
>
>
>
> ________________________________
> From: "Echlin, Robert" <Ro...@windriver.com>
> To: Ant Users List <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 1:29:18 PM
> Subject: RE: Do things based on project success or failure
>
> Hi Eric,
> I didn't get that ant was failing out on you. Sorry.
> I will check on that.
>
> Rob
>
>> -----Original Message-----
>> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
>> Sent: Thursday, June 02, 2011 2:22 PM
>> To: Ant Users List
>> Subject: Re: Do things based on project success or failure
>>
>> Thanks Robert, I've already got the db stuff working using
>> jdbc and <sql>. Of course with a mysql database, it didn't
>> work until I added perms for the user from the IP that I'm
>> talking to it on:
>>
>> grant all on dbname.* to 'username'@'ip.addy' identified by
>> 'userpassword';
>>
>> I don't see, however, how antcall or subant will solve my
>> issue with being able to do something after the build fails.
>> Ant turns tail and runs after a failure, there is no saying:
>> onFailure DO... That's why I'm calling it from the exec task.
>> Then I separate from the process and gather a return code on
>> the other side... Maybe I'm missing something.
>>
>> Thanks,
>> Eric
>>
>>
>>
>>
>> ________________________________
>> From: "Echlin, Robert" <Ro...@windriver.com>
>> To: Ant Users List <us...@ant.apache.org>
>> Sent: Thu, June 2, 2011 10:02:02 AM
>> Subject: RE: Do things based on project success or failure
>>
>> Hi Eric,
>> Look up "subant" and "antcall" for a start. They are in "core tasks".
>> If you put both tasks in the same xml file, you will use "antcall".
>>
>> Also, for your DB operation, look up "sql" task, which uses JDBC.
>>
>> Rob
>>
>> --
>> Rob Echlin, Documentation Systems Architect, Wind River
>> direct: +1.613.270.5796 | robert.echlin@windriver.com
>>
>>
>>> -----Original Message-----
>>> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
>>> Sent: Thursday, June 02, 2011 11:20 AM
>>> To: Ant Users List
>>> Subject: Re: Do things based on project success or failure
>>>
>>> Of course this presents me another issue. How do I gather
>> up all of
>>> the command line arguments that were passed to me so that I can
>>> re-pass them to the next ant script. Is there a way to say:
>>> <property name="allArgs"
>>> value="allOfMyArgsThatWerePassedToMe"/>?
>>>
>>> Thanks,
>>> Eric
>>>
>>>
>>>
>>>
>>> ________________________________
>>> From: Eric Fetzer <el...@yahoo.com>
>>> To: Ant Users <us...@ant.apache.org>
>>> Sent: Thu, June 2, 2011 9:02:14 AM
>>> Subject: Do things based on project success or failure
>>>
>>> I have to update a database one way or another based on project
>>> success or failure. So I'm messing around with the <exec>
>> task with
>>> errorproperty attribute. I'm trying to make it so that
>> failure will
>>> test one way vs. success testing another. The best thing I
>> can come
>>> up with is the following:
>>>
>>> <----------------------------------------------------------------->
>>> Build File 1:
>>>
>>> <project name="test" default="test">
>>> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
>>> <target name="test">
>>> <exec dir="." executable="cmd.exe" errorproperty="returncode">
>>> <arg line="/c ant -f test2.xml -Dgood=${good}"/>
>>> </exec>
>>> <echo message="returncode is: ${returncode}"/>
>>>
>>> <if>
>>> <equals arg1="${returncode}" arg2="" />
>>> <then>
>>> <echo message="It succeeded"/>
>>> </then>
>>> <else>
>>> <echo message="It failed"/>
>>> </else>
>>> </if>
>>> </target>
>>> </project>
>>>
>>> Build File 2:
>>>
>>> <project name="test2" default="test">
>>> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
>>> <target name="test">
>>> <if>
>>> <equals arg1="${good}" arg2="true" />
>>> <then>
>>> <echo message="Good!"/>
>>> </then>
>>> <else>
>>> <echo message="Bad"/>
>>> <fail/>
>>> </else>
>>> </if>
>>> </target>
>>> </project>
>>>
>>> </----------------------------------------------------------------->
>>>
>>> So if I pass >ant -f test.xml -Dgood="true"
>>> I end up in the success code. Or if I pass >ant -f test.xml
>>> -Dgood="anythingElse"
>>> I end up in the failure code.
>>>
>>> Does anyone have a more graceful way to do this?
>>>
>>> Thanks,
>>> Eric
>> ---------------------------------------------------------------------
>> 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
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
That seems a whole lot easier, thanks! I'll give that a shot. That way I can
use the <ant> task and allow the args to just be inherited...
________________________________
From: Vimil Saju <vi...@yahoo.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 1:37:26 PM
Subject: Re: Do things based on project success or failure
You could also use the trycatch task from antcontrib. the try task has a catch
block that executes when any of the tasks within the try block fails.
--- On Thu, 6/2/11, Eric Fetzer <el...@yahoo.com> wrote:
From: Eric Fetzer <el...@yahoo.com>
Subject: Re: Do things based on project success or failure
To: "Ant Users List" <us...@ant.apache.org>
Date: Thursday, June 2, 2011, 12:31 PM
No problem Rob! The way I posted works great, I was just wondering if there was
a more graceful way to do it. I think I can get the properties to pass as well
with the echoproperties task... Thanks!
________________________________
From: "Echlin, Robert" <Ro...@windriver.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 1:29:18 PM
Subject: RE: Do things based on project success or failure
Hi Eric,
I didn't get that ant was failing out on you. Sorry.
I will check on that.
Rob
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 2:22 PM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Thanks Robert, I've already got the db stuff working using
> jdbc and <sql>. Of course with a mysql database, it didn't
> work until I added perms for the user from the IP that I'm
> talking to it on:
>
> grant all on dbname.* to 'username'@'ip.addy' identified by
> 'userpassword';
>
> I don't see, however, how antcall or subant will solve my
> issue with being able to do something after the build fails.
> Ant turns tail and runs after a failure, there is no saying:
> onFailure DO... That's why I'm calling it from the exec task.
> Then I separate from the process and gather a return code on
> the other side... Maybe I'm missing something.
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: "Echlin, Robert" <Ro...@windriver.com>
> To: Ant Users List <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 10:02:02 AM
> Subject: RE: Do things based on project success or failure
>
> Hi Eric,
> Look up "subant" and "antcall" for a start. They are in "core tasks".
> If you put both tasks in the same xml file, you will use "antcall".
>
> Also, for your DB operation, look up "sql" task, which uses JDBC.
>
> Rob
>
> --
> Rob Echlin, Documentation Systems Architect, Wind River
> direct: +1.613.270.5796 | robert.echlin@windriver.com
>
>
> > -----Original Message-----
> > From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> > Sent: Thursday, June 02, 2011 11:20 AM
> > To: Ant Users List
> > Subject: Re: Do things based on project success or failure
> >
> > Of course this presents me another issue. How do I gather
> up all of
> > the command line arguments that were passed to me so that I can
> > re-pass them to the next ant script. Is there a way to say:
> > <property name="allArgs"
> > value="allOfMyArgsThatWerePassedToMe"/>?
> >
> > Thanks,
> > Eric
> >
> >
> >
> >
> > ________________________________
> > From: Eric Fetzer <el...@yahoo.com>
> > To: Ant Users <us...@ant.apache.org>
> > Sent: Thu, June 2, 2011 9:02:14 AM
> > Subject: Do things based on project success or failure
> >
> > I have to update a database one way or another based on project
> > success or failure. So I'm messing around with the <exec>
> task with
> > errorproperty attribute. I'm trying to make it so that
> failure will
> > test one way vs. success testing another. The best thing I
> can come
> > up with is the following:
> >
> > <----------------------------------------------------------------->
> > Build File 1:
> >
> > <project name="test" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <exec dir="." executable="cmd.exe" errorproperty="returncode">
> > <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> > </exec>
> > <echo message="returncode is: ${returncode}"/>
> >
> > <if>
> > <equals arg1="${returncode}" arg2="" />
> > <then>
> > <echo message="It succeeded"/>
> > </then>
> > <else>
> > <echo message="It failed"/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > Build File 2:
> >
> > <project name="test2" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <if>
> > <equals arg1="${good}" arg2="true" />
> > <then>
> > <echo message="Good!"/>
> > </then>
> > <else>
> > <echo message="Bad"/>
> > <fail/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > </----------------------------------------------------------------->
> >
> > So if I pass >ant -f test.xml -Dgood="true"
> > I end up in the success code. Or if I pass >ant -f test.xml
> > -Dgood="anythingElse"
> > I end up in the failure code.
> >
> > Does anyone have a more graceful way to do this?
> >
> > Thanks,
> > Eric
> ---------------------------------------------------------------------
> 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
Re: Do things based on project success or failure
Posted by Vimil Saju <vi...@yahoo.com>.
You could also use the trycatch task from antcontrib. the try task has a catch block that executes when any of the tasks within the try block fails.
--- On Thu, 6/2/11, Eric Fetzer <el...@yahoo.com> wrote:
From: Eric Fetzer <el...@yahoo.com>
Subject: Re: Do things based on project success or failure
To: "Ant Users List" <us...@ant.apache.org>
Date: Thursday, June 2, 2011, 12:31 PM
No problem Rob! The way I posted works great, I was just wondering if there was
a more graceful way to do it. I think I can get the properties to pass as well
with the echoproperties task... Thanks!
________________________________
From: "Echlin, Robert" <Ro...@windriver.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 1:29:18 PM
Subject: RE: Do things based on project success or failure
Hi Eric,
I didn't get that ant was failing out on you. Sorry.
I will check on that.
Rob
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 2:22 PM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Thanks Robert, I've already got the db stuff working using
> jdbc and <sql>. Of course with a mysql database, it didn't
> work until I added perms for the user from the IP that I'm
> talking to it on:
>
> grant all on dbname.* to 'username'@'ip.addy' identified by
> 'userpassword';
>
> I don't see, however, how antcall or subant will solve my
> issue with being able to do something after the build fails.
> Ant turns tail and runs after a failure, there is no saying:
> onFailure DO... That's why I'm calling it from the exec task.
> Then I separate from the process and gather a return code on
> the other side... Maybe I'm missing something.
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: "Echlin, Robert" <Ro...@windriver.com>
> To: Ant Users List <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 10:02:02 AM
> Subject: RE: Do things based on project success or failure
>
> Hi Eric,
> Look up "subant" and "antcall" for a start. They are in "core tasks".
> If you put both tasks in the same xml file, you will use "antcall".
>
> Also, for your DB operation, look up "sql" task, which uses JDBC.
>
> Rob
>
> --
> Rob Echlin, Documentation Systems Architect, Wind River
> direct: +1.613.270.5796 | robert.echlin@windriver.com
>
>
> > -----Original Message-----
> > From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> > Sent: Thursday, June 02, 2011 11:20 AM
> > To: Ant Users List
> > Subject: Re: Do things based on project success or failure
> >
> > Of course this presents me another issue. How do I gather
> up all of
> > the command line arguments that were passed to me so that I can
> > re-pass them to the next ant script. Is there a way to say:
> > <property name="allArgs"
> > value="allOfMyArgsThatWerePassedToMe"/>?
> >
> > Thanks,
> > Eric
> >
> >
> >
> >
> > ________________________________
> > From: Eric Fetzer <el...@yahoo.com>
> > To: Ant Users <us...@ant.apache.org>
> > Sent: Thu, June 2, 2011 9:02:14 AM
> > Subject: Do things based on project success or failure
> >
> > I have to update a database one way or another based on project
> > success or failure. So I'm messing around with the <exec>
> task with
> > errorproperty attribute. I'm trying to make it so that
> failure will
> > test one way vs. success testing another. The best thing I
> can come
> > up with is the following:
> >
> > <----------------------------------------------------------------->
> > Build File 1:
> >
> > <project name="test" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <exec dir="." executable="cmd.exe" errorproperty="returncode">
> > <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> > </exec>
> > <echo message="returncode is: ${returncode}"/>
> >
> > <if>
> > <equals arg1="${returncode}" arg2="" />
> > <then>
> > <echo message="It succeeded"/>
> > </then>
> > <else>
> > <echo message="It failed"/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > Build File 2:
> >
> > <project name="test2" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <if>
> > <equals arg1="${good}" arg2="true" />
> > <then>
> > <echo message="Good!"/>
> > </then>
> > <else>
> > <echo message="Bad"/>
> > <fail/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > </----------------------------------------------------------------->
> >
> > So if I pass >ant -f test.xml -Dgood="true"
> > I end up in the success code. Or if I pass >ant -f test.xml
> > -Dgood="anythingElse"
> > I end up in the failure code.
> >
> > Does anyone have a more graceful way to do this?
> >
> > Thanks,
> > Eric
> ---------------------------------------------------------------------
> 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
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
No problem Rob! The way I posted works great, I was just wondering if there was
a more graceful way to do it. I think I can get the properties to pass as well
with the echoproperties task... Thanks!
________________________________
From: "Echlin, Robert" <Ro...@windriver.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 1:29:18 PM
Subject: RE: Do things based on project success or failure
Hi Eric,
I didn't get that ant was failing out on you. Sorry.
I will check on that.
Rob
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 2:22 PM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Thanks Robert, I've already got the db stuff working using
> jdbc and <sql>. Of course with a mysql database, it didn't
> work until I added perms for the user from the IP that I'm
> talking to it on:
>
> grant all on dbname.* to 'username'@'ip.addy' identified by
> 'userpassword';
>
> I don't see, however, how antcall or subant will solve my
> issue with being able to do something after the build fails.
> Ant turns tail and runs after a failure, there is no saying:
> onFailure DO... That's why I'm calling it from the exec task.
> Then I separate from the process and gather a return code on
> the other side... Maybe I'm missing something.
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: "Echlin, Robert" <Ro...@windriver.com>
> To: Ant Users List <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 10:02:02 AM
> Subject: RE: Do things based on project success or failure
>
> Hi Eric,
> Look up "subant" and "antcall" for a start. They are in "core tasks".
> If you put both tasks in the same xml file, you will use "antcall".
>
> Also, for your DB operation, look up "sql" task, which uses JDBC.
>
> Rob
>
> --
> Rob Echlin, Documentation Systems Architect, Wind River
> direct: +1.613.270.5796 | robert.echlin@windriver.com
>
>
> > -----Original Message-----
> > From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> > Sent: Thursday, June 02, 2011 11:20 AM
> > To: Ant Users List
> > Subject: Re: Do things based on project success or failure
> >
> > Of course this presents me another issue. How do I gather
> up all of
> > the command line arguments that were passed to me so that I can
> > re-pass them to the next ant script. Is there a way to say:
> > <property name="allArgs"
> > value="allOfMyArgsThatWerePassedToMe"/>?
> >
> > Thanks,
> > Eric
> >
> >
> >
> >
> > ________________________________
> > From: Eric Fetzer <el...@yahoo.com>
> > To: Ant Users <us...@ant.apache.org>
> > Sent: Thu, June 2, 2011 9:02:14 AM
> > Subject: Do things based on project success or failure
> >
> > I have to update a database one way or another based on project
> > success or failure. So I'm messing around with the <exec>
> task with
> > errorproperty attribute. I'm trying to make it so that
> failure will
> > test one way vs. success testing another. The best thing I
> can come
> > up with is the following:
> >
> > <----------------------------------------------------------------->
> > Build File 1:
> >
> > <project name="test" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <exec dir="." executable="cmd.exe" errorproperty="returncode">
> > <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> > </exec>
> > <echo message="returncode is: ${returncode}"/>
> >
> > <if>
> > <equals arg1="${returncode}" arg2="" />
> > <then>
> > <echo message="It succeeded"/>
> > </then>
> > <else>
> > <echo message="It failed"/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > Build File 2:
> >
> > <project name="test2" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <if>
> > <equals arg1="${good}" arg2="true" />
> > <then>
> > <echo message="Good!"/>
> > </then>
> > <else>
> > <echo message="Bad"/>
> > <fail/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > </----------------------------------------------------------------->
> >
> > So if I pass >ant -f test.xml -Dgood="true"
> > I end up in the success code. Or if I pass >ant -f test.xml
> > -Dgood="anythingElse"
> > I end up in the failure code.
> >
> > Does anyone have a more graceful way to do this?
> >
> > Thanks,
> > Eric
> ---------------------------------------------------------------------
> 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
RE: Do things based on project success or failure
Posted by "Echlin, Robert" <Ro...@windriver.com>.
Hi Eric,
I didn't get that ant was failing out on you. Sorry.
I will check on that.
Rob
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 2:22 PM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Thanks Robert, I've already got the db stuff working using
> jdbc and <sql>. Of course with a mysql database, it didn't
> work until I added perms for the user from the IP that I'm
> talking to it on:
>
> grant all on dbname.* to 'username'@'ip.addy' identified by
> 'userpassword';
>
> I don't see, however, how antcall or subant will solve my
> issue with being able to do something after the build fails.
> Ant turns tail and runs after a failure, there is no saying:
> onFailure DO... That's why I'm calling it from the exec task.
> Then I separate from the process and gather a return code on
> the other side... Maybe I'm missing something.
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: "Echlin, Robert" <Ro...@windriver.com>
> To: Ant Users List <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 10:02:02 AM
> Subject: RE: Do things based on project success or failure
>
> Hi Eric,
> Look up "subant" and "antcall" for a start. They are in "core tasks".
> If you put both tasks in the same xml file, you will use "antcall".
>
> Also, for your DB operation, look up "sql" task, which uses JDBC.
>
> Rob
>
> --
> Rob Echlin, Documentation Systems Architect, Wind River
> direct: +1.613.270.5796 | robert.echlin@windriver.com
>
>
> > -----Original Message-----
> > From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> > Sent: Thursday, June 02, 2011 11:20 AM
> > To: Ant Users List
> > Subject: Re: Do things based on project success or failure
> >
> > Of course this presents me another issue. How do I gather
> up all of
> > the command line arguments that were passed to me so that I can
> > re-pass them to the next ant script. Is there a way to say:
> > <property name="allArgs"
> > value="allOfMyArgsThatWerePassedToMe"/>?
> >
> > Thanks,
> > Eric
> >
> >
> >
> >
> > ________________________________
> > From: Eric Fetzer <el...@yahoo.com>
> > To: Ant Users <us...@ant.apache.org>
> > Sent: Thu, June 2, 2011 9:02:14 AM
> > Subject: Do things based on project success or failure
> >
> > I have to update a database one way or another based on project
> > success or failure. So I'm messing around with the <exec>
> task with
> > errorproperty attribute. I'm trying to make it so that
> failure will
> > test one way vs. success testing another. The best thing I
> can come
> > up with is the following:
> >
> > <----------------------------------------------------------------->
> > Build File 1:
> >
> > <project name="test" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <exec dir="." executable="cmd.exe" errorproperty="returncode">
> > <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> > </exec>
> > <echo message="returncode is: ${returncode}"/>
> >
> > <if>
> > <equals arg1="${returncode}" arg2="" />
> > <then>
> > <echo message="It succeeded"/>
> > </then>
> > <else>
> > <echo message="It failed"/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > Build File 2:
> >
> > <project name="test2" default="test">
> > <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> > <target name="test">
> > <if>
> > <equals arg1="${good}" arg2="true" />
> > <then>
> > <echo message="Good!"/>
> > </then>
> > <else>
> > <echo message="Bad"/>
> > <fail/>
> > </else>
> > </if>
> > </target>
> > </project>
> >
> > </----------------------------------------------------------------->
> >
> > So if I pass >ant -f test.xml -Dgood="true"
> > I end up in the success code. Or if I pass >ant -f test.xml
> > -Dgood="anythingElse"
> > I end up in the failure code.
> >
> > Does anyone have a more graceful way to do this?
> >
> > Thanks,
> > Eric
> ---------------------------------------------------------------------
> 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
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
Thanks Robert, I've already got the db stuff working using jdbc and <sql>. Of
course with a mysql database, it didn't work until I added perms for the user
from the IP that I'm talking to it on:
grant all on dbname.* to 'username'@'ip.addy' identified by 'userpassword';
I don't see, however, how antcall or subant will solve my issue with being able
to do something after the build fails. Ant turns tail and runs after a failure,
there is no saying: onFailure DO... That's why I'm calling it from the exec
task. Then I separate from the process and gather a return code on the other
side... Maybe I'm missing something.
Thanks,
Eric
________________________________
From: "Echlin, Robert" <Ro...@windriver.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 10:02:02 AM
Subject: RE: Do things based on project success or failure
Hi Eric,
Look up "subant" and "antcall" for a start. They are in "core tasks".
If you put both tasks in the same xml file, you will use "antcall".
Also, for your DB operation, look up "sql" task, which uses JDBC.
Rob
--
Rob Echlin, Documentation Systems Architect, Wind River
direct: +1.613.270.5796 | robert.echlin@windriver.com
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 11:20 AM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Of course this presents me another issue. How do I gather up
> all of the command line arguments that were passed to me so
> that I can re-pass them to the next ant script. Is there a
> way to say: <property name="allArgs"
> value="allOfMyArgsThatWerePassedToMe"/>?
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: Eric Fetzer <el...@yahoo.com>
> To: Ant Users <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 9:02:14 AM
> Subject: Do things based on project success or failure
>
> I have to update a database one way or another based on
> project success or failure. So I'm messing around with the
> <exec> task with errorproperty attribute. I'm trying to make
> it so that failure will test one way vs. success testing
> another. The best thing I can come up with is the following:
>
> <----------------------------------------------------------------->
> Build File 1:
>
> <project name="test" default="test">
> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> <target name="test">
> <exec dir="." executable="cmd.exe" errorproperty="returncode">
> <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> </exec>
> <echo message="returncode is: ${returncode}"/>
>
> <if>
> <equals arg1="${returncode}" arg2="" />
> <then>
> <echo message="It succeeded"/>
> </then>
> <else>
> <echo message="It failed"/>
> </else>
> </if>
> </target>
> </project>
>
> Build File 2:
>
> <project name="test2" default="test">
> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> <target name="test">
> <if>
> <equals arg1="${good}" arg2="true" />
> <then>
> <echo message="Good!"/>
> </then>
> <else>
> <echo message="Bad"/>
> <fail/>
> </else>
> </if>
> </target>
> </project>
>
> </----------------------------------------------------------------->
>
> So if I pass >ant -f test.xml -Dgood="true"
> I end up in the success code. Or if I pass >ant -f test.xml
> -Dgood="anythingElse"
> I end up in the failure code.
>
> Does anyone have a more graceful way to do this?
>
> Thanks,
> Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Do things based on project success or failure
Posted by "Echlin, Robert" <Ro...@windriver.com>.
Hi Eric,
Look up "subant" and "antcall" for a start. They are in "core tasks".
If you put both tasks in the same xml file, you will use "antcall".
Also, for your DB operation, look up "sql" task, which uses JDBC.
Rob
--
Rob Echlin, Documentation Systems Architect, Wind River
direct: +1.613.270.5796 | robert.echlin@windriver.com
> -----Original Message-----
> From: Eric Fetzer [mailto:elstonkers@yahoo.com]
> Sent: Thursday, June 02, 2011 11:20 AM
> To: Ant Users List
> Subject: Re: Do things based on project success or failure
>
> Of course this presents me another issue. How do I gather up
> all of the command line arguments that were passed to me so
> that I can re-pass them to the next ant script. Is there a
> way to say: <property name="allArgs"
> value="allOfMyArgsThatWerePassedToMe"/>?
>
> Thanks,
> Eric
>
>
>
>
> ________________________________
> From: Eric Fetzer <el...@yahoo.com>
> To: Ant Users <us...@ant.apache.org>
> Sent: Thu, June 2, 2011 9:02:14 AM
> Subject: Do things based on project success or failure
>
> I have to update a database one way or another based on
> project success or failure. So I'm messing around with the
> <exec> task with errorproperty attribute. I'm trying to make
> it so that failure will test one way vs. success testing
> another. The best thing I can come up with is the following:
>
> <----------------------------------------------------------------->
> Build File 1:
>
> <project name="test" default="test">
> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> <target name="test">
> <exec dir="." executable="cmd.exe" errorproperty="returncode">
> <arg line="/c ant -f test2.xml -Dgood=${good}"/>
> </exec>
> <echo message="returncode is: ${returncode}"/>
>
> <if>
> <equals arg1="${returncode}" arg2="" />
> <then>
> <echo message="It succeeded"/>
> </then>
> <else>
> <echo message="It failed"/>
> </else>
> </if>
> </target>
> </project>
>
> Build File 2:
>
> <project name="test2" default="test">
> <taskdef resource="net/sf/antcontrib/antlib.xml"/>
> <target name="test">
> <if>
> <equals arg1="${good}" arg2="true" />
> <then>
> <echo message="Good!"/>
> </then>
> <else>
> <echo message="Bad"/>
> <fail/>
> </else>
> </if>
> </target>
> </project>
>
> </----------------------------------------------------------------->
>
> So if I pass >ant -f test.xml -Dgood="true"
> I end up in the success code. Or if I pass >ant -f test.xml
> -Dgood="anythingElse"
> I end up in the failure code.
>
> Does anyone have a more graceful way to do this?
>
> Thanks,
> Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
Not sure what you're answering here Robert. Are you saying inside the exists
target, call the other build file with subant and if it succeeds it will go to
do.true or do.false?
Thanks,
Eric
________________________________
From: "Echlin, Robert" <Ro...@windriver.com>
To: Ant Users List <us...@ant.apache.org>
Sent: Thu, June 2, 2011 10:43:05 AM
Subject: RE: Do things based on project success or failure
Hi Eric,
(code below)
Try the "depends with if/unless" pattern.
Note the "if" and "unless" parameters on the do.true and do.false targets.
"condition" sets a variable depending on something - in this case where a file
exists or not.
The "top" level target does nothing except make sure other things happen in
order.
You might call that pattern "empty target orders actions".
Rob
---------
File check.xml:
<?xml version="1.0" encoding="utf-8"?>
<project name="Build rules for documentation sets" default="top">
<target name="top" description="Does the given file exist?" depends="exists,
do.true, do.false"/>
<target name="exists"
description="Check if a file exists">
<condition property="file.exists">
<available file="${file.name}"/>
</condition>
</target>
<target name="do.true" if="file.exists">
<echo>yay! it's true!</echo>
</target>
<target name="do.false" unless="file.exists">
<echo>Darn! Try again!</echo>
</target>
</project>
---------
Output of tests:
C:\depends-if>ant -f check.xml -Dfile.nam
=check.xml
Buildfile: C:\Documents and Settings\rechlin\My
Documents\test\TEST-ant\depends-if\check.xml
exists:
do.true:
[echo] yay! it's true!
do.false:
top:
BUILD SUCCESSFUL
Total time: 0 seconds
C:\depends-if>ant -f check.xml -Dfile.nam
=check.xmlOFF
Buildfile: C:\Documents and Settings\rechlin\My
Documents\test\TEST-ant\depends-if\check.xml
exists:
do.true:
do.false:
[echo] Darn! Try again!
top:
BUILD SUCCESSFUL
Total time: 0 seconds
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
RE: Do things based on project success or failure
Posted by "Echlin, Robert" <Ro...@windriver.com>.
Hi Eric,
(code below)
Try the "depends with if/unless" pattern.
Note the "if" and "unless" parameters on the do.true and do.false targets.
"condition" sets a variable depending on something - in this case where a file exists or not.
The "top" level target does nothing except make sure other things happen in order.
You might call that pattern "empty target orders actions".
Rob
---------
File check.xml:
<?xml version="1.0" encoding="utf-8"?>
<project name="Build rules for documentation sets" default="top">
<target name="top" description="Does the given file exist?" depends="exists, do.true, do.false"/>
<target name="exists"
description="Check if a file exists">
<condition property="file.exists">
<available file="${file.name}"/>
</condition>
</target>
<target name="do.true" if="file.exists">
<echo>yay! it's true!</echo>
</target>
<target name="do.false" unless="file.exists">
<echo>Darn! Try again!</echo>
</target>
</project>
---------
Output of tests:
C:\depends-if>ant -f check.xml -Dfile.nam
=check.xml
Buildfile: C:\Documents and Settings\rechlin\My Documents\test\TEST-ant\depends-if\check.xml
exists:
do.true:
[echo] yay! it's true!
do.false:
top:
BUILD SUCCESSFUL
Total time: 0 seconds
C:\depends-if>ant -f check.xml -Dfile.nam
=check.xmlOFF
Buildfile: C:\Documents and Settings\rechlin\My Documents\test\TEST-ant\depends-if\check.xml
exists:
do.true:
do.false:
[echo] Darn! Try again!
top:
BUILD SUCCESSFUL
Total time: 0 seconds
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Do things based on project success or failure
Posted by Eric Fetzer <el...@yahoo.com>.
Of course this presents me another issue. How do I gather up all of the command
line arguments that were passed to me so that I can re-pass them to the next ant
script. Is there a way to say: <property name="allArgs"
value="allOfMyArgsThatWerePassedToMe"/>?
Thanks,
Eric
________________________________
From: Eric Fetzer <el...@yahoo.com>
To: Ant Users <us...@ant.apache.org>
Sent: Thu, June 2, 2011 9:02:14 AM
Subject: Do things based on project success or failure
I have to update a database one way or another based on project success or
failure. So I'm messing around with the <exec> task with errorproperty
attribute. I'm trying to make it so that failure will test one way vs. success
testing another. The best thing I can come up with is the following:
<----------------------------------------------------------------->
Build File 1:
<project name="test" default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="test">
<exec dir="." executable="cmd.exe" errorproperty="returncode">
<arg line="/c ant -f test2.xml -Dgood=${good}"/>
</exec>
<echo message="returncode is: ${returncode}"/>
<if>
<equals arg1="${returncode}" arg2="" />
<then>
<echo message="It succeeded"/>
</then>
<else>
<echo message="It failed"/>
</else>
</if>
</target>
</project>
Build File 2:
<project name="test2" default="test">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="test">
<if>
<equals arg1="${good}" arg2="true" />
<then>
<echo message="Good!"/>
</then>
<else>
<echo message="Bad"/>
<fail/>
</else>
</if>
</target>
</project>
</----------------------------------------------------------------->
So if I pass >ant -f test.xml -Dgood="true"
I end up in the success code. Or if I pass >ant -f test.xml
-Dgood="anythingElse"
I end up in the failure code.
Does anyone have a more graceful way to do this?
Thanks,
Eric