Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
AW: Is there a way to fail a build from inside the script task?

AW: Is there a way to fail a build from inside the script task?

2003-03-19       - By Jan.Materne@(protected)

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" basedir="." default="main">
   <target name="main">

       <property name="flag" value="echo"/>

       <script language="javascript"> <![CDATA[

            // Access to the flag property value
            fl = self.getProject().getProperty("flag");

            // Evaluate
            if (fl == 'fail') {
                // use the id-Attribute
                doFail.setMessage("fail-message");
                doFail.perform();
            } else {
                doEcho.setMessage("ok");
                doEcho.perform();
            }
       ]]>
       </script>

   </target>


   <!--
     The target begins with a '-' so it can?t be invoked from
     command line. It defines tasks used in the script task.
     These tasks have an id-Attribute so they can be referenced
     by these id in the script.
   -->
   <target name="-internalUsed">
       <fail id="doFail"/>
       <echo id="doEcho"/>
   </target>

</project>


>ant
Buildfile: build.xml
main:
    [echo] ok
BUILD SUCCESSFUL


>ant -Dflag=fail
Buildfile: build.xml
main:
BUILD FAILED
/build.xml:28: fail-message


Jan Mat?rne

-----Urspr?ngliche Nachricht-----
Von: Craig Dickson [mailto:craig.dickson@(protected)]
Gesendet am: Mittwoch, 19. M?rz 2003 00:08
An: 'user@(protected)'
Betreff: Is there a way to fail a build from inside the script task?



©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.