Grokbase Groups Ant user June 2009
FAQ
Is there a way to end a build prematurely, successfully? I can use <fail>, but then the return value of ant is a failure and it prints out BUILD FAILED, which will make the user think something bad happened. That was not the case. I want to stop a build in certain circumstances and have it be normal and successful. How could I write my own task to do this?

---
Shawn Castrianni

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Search Discussions

  • Michael Alsen at Jun 15, 2009 at 6:54 am
    Instaed of calling <fail /> you could call a target e.g.: <target name="noop"
    />.


    Shawn Castrianni wrote:
    Is there a way to end a build prematurely, successfully? I can use
    <fail>, but then the return value of ant is a failure and it prints out
    BUILD FAILED, which will make the user think something bad happened. That
    was not the case. I want to stop a build in certain circumstances and
    have it be normal and successful. How could I write my own task to do
    this?

    ---
    Shawn Castrianni

    ----------------------------------------------------------------------
    This e-mail, including any attached files, may contain confidential and
    privileged information for the sole use of the intended recipient. Any
    review, use, distribution, or disclosure by others is strictly prohibited.
    If you are not the intended recipient (or authorized to receive
    information for the intended recipient), please contact the sender by
    reply e-mail and delete all copies of this message.
    --
    View this message in context: http://www.nabble.com/Abort-build-with-successful-status-tp24028937p24029559.html
    Sent from the Ant - Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Steve Loughran at Jun 15, 2009 at 11:44 am
    You could fail but set the exit code to 0. It will still print fail,
    though that is actually the job of the logger. There's no reason why a
    custom logger cant skip that fail message if the exit code is 0, or even
    print out whatever the exception message text is that <fail> raises.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Knuplesch, Juergen at Jun 15, 2009 at 7:12 am
    Hello,

    I would use <if> from antcontrib to achieve this.

    Sth.like
    <if>
    <equals arg1="true" arg2="${longbuild}" />
    <then>
    <domore...>
    </then>
    </if>

    --
    Jürgen Knuplesch
    -----Ursprüngliche Nachricht-----
    Von: Shawn Castrianni
    Gesendet: Montag, 15. Juni 2009 07:18
    An: 'user@ant.apache.org'
    Betreff: Abort build with successful status

    Is there a way to end a build prematurely, successfully? I can use <fail>, but then the return value of ant is a failure and it prints out BUILD FAILED, which will make the user think something bad happened. That was not the case. I want to stop a build in certain circumstances and have it be normal and successful. How could I write my own task to do this?

    ---
    Shawn Castrianni

    ----------------------------------------------------------------------
    This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Matt Benson at Jun 15, 2009 at 12:43 pm
    <fail status="0" />

    --- On Mon, 6/15/09, Shawn Castrianni wrote:
    From: Shawn Castrianni <Shawn.Castrianni@halliburton.com>
    Subject: Abort build with successful status
    To: "'user@ant.apache.org'" <user@ant.apache.org>
    Date: Monday, June 15, 2009, 12:18 AM
    Is there a way to end a build
    prematurely, successfully?  I can use <fail>, but
    then the return value of ant is a failure and it prints out
    BUILD FAILED, which will make the user think something bad
    happened.  That was not the case.  I want to stop
    a build in certain circumstances and have it be normal and
    successful.  How could I write my own task to do this?

    ---
    Shawn Castrianni

    ----------------------------------------------------------------------
    This e-mail, including any attached files, may contain
    confidential and privileged information for the sole use of
    the intended recipient.  Any review, use, distribution,
    or disclosure by others is strictly prohibited.  If you
    are not the intended recipient (or authorized to receive
    information for the intended recipient), please contact the
    sender by reply e-mail and delete all copies of this
    message.



    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Matt Benson at Jun 15, 2009 at 1:13 pm
    Ah, I had already replied similarly before seeing your response, Steve. :)

    --- On Mon, 6/15/09, Steve Loughran wrote:
    From: Steve Loughran <stevel@apache.org>
    Subject: Re: Abort build with successful status
    To: "Ant Users List" <user@ant.apache.org>
    Date: Monday, June 15, 2009, 6:43 AM
    You could fail but set the exit code
    to 0. It will still print fail, though that is actually the
    job of the logger. There's no reason why a custom logger
    cant skip that fail message if the exit code is 0, or even
    print out whatever the exception message text is that
    <fail> raises.

    ---------------------------------------------------------------------
    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
  • Shawn Castrianni at Jun 15, 2009 at 4:27 pm
    I think as mentioned, that this approach would solve the ANT return code, but would still print out BUILD FAILED. Poking around the source code of ANT, (I love open source). I found a perfect solution by writing my own task. See below. It uses the fireBuildFinished method from the Project. It works great and even prints out the Total time: message at the end of the build like normal.



    package com.lgc.btlite;

    import org.apache.tools.ant.Project;
    import org.apache.tools.ant.Task;

    public class EndTask extends Task {
    protected String _message = null;

    public void execute()
    {
    if((_message != null) && (_message.length() > 0))
    log("\n" + _message,Project.MSG_INFO);
    getProject().fireBuildFinished(null);
    System.exit(0);
    }

    public void setMessage(String message)
    {
    _message = message;
    }
    }

    ---
    Shawn Castrianni

    -----Original Message-----
    From: Matt Benson
    Sent: Monday, June 15, 2009 8:14 AM
    To: Ant Users List
    Subject: Re: Abort build with successful status


    Ah, I had already replied similarly before seeing your response, Steve. :)

    --- On Mon, 6/15/09, Steve Loughran wrote:
    From: Steve Loughran <stevel@apache.org>
    Subject: Re: Abort build with successful status
    To: "Ant Users List" <user@ant.apache.org>
    Date: Monday, June 15, 2009, 6:43 AM
    You could fail but set the exit code
    to 0. It will still print fail, though that is actually the
    job of the logger. There's no reason why a custom logger
    cant skip that fail message if the exit code is 0, or even
    print out whatever the exception message text is that
    <fail> raises.

    ---------------------------------------------------------------------
    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

    ----------------------------------------------------------------------
    This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • David Weintraub at Jun 15, 2009 at 6:43 pm
    Can you be more specific what you want to do?

    In what circumstance do you want to suddenly stop your build process, but
    consider it a success?

    Let's say you want to do "A", "B", and "C" as three tasks in a build, can't
    you simply make them targets with dependencies: "C" depends upon "B" and "B"
    depends upon "A". If I don't want to run "C", I can merely say run target
    "B".

    Let's say that I want to do "A", "B", and "C", but "C" is mainly a testing
    task, and if the server isn't available for testing, I just want to forget
    about it. In that case, I can make "C" dependent upon "C-prime" and only run
    "C" if "C-prime" is successful. In that case, I have "C-prime" set a
    property, and if the property isn't set, I don't execute "C":

    <target name="C"
    depends="C-Prime"
    if="C-Prime.ran.successfully">

    On Mon, Jun 15, 2009 at 1:18 AM, Shawn Castrianni wrote:

    Is there a way to end a build prematurely, successfully? I can use <fail>,
    but then the return value of ant is a failure and it prints out BUILD
    FAILED, which will make the user think something bad happened. That was not
    the case. I want to stop a build in certain circumstances and have it be
    normal and successful. How could I write my own task to do this?

    ---
    Shawn Castrianni

    ----------------------------------------------------------------------
    This e-mail, including any attached files, may contain confidential and
    privileged information for the sole use of the intended recipient. Any
    review, use, distribution, or disclosure by others is strictly prohibited.
    If you are not the intended recipient (or authorized to receive information
    for the intended recipient), please contact the sender by reply e-mail and
    delete all copies of this message.


    --
    David Weintraub
    qazwart@gmail.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedJun 15, '09 at 5:19a
activeJun 15, '09 at 6:43p
posts8
users6
websiteant.apache.org

People

Translate

site design / logo © 2022 Grokbase