git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270241 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1,84 +0,0 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE file. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | |||||
| /** | |||||
| * Just exit the active build, giving an additional message if available. | |||||
| * | |||||
| * @author <a href="mailto:nico@seessle.de">Nico Seessle</a> | |||||
| */ | |||||
| public class Exit extends Task | |||||
| { | |||||
| private String ifCondition, unlessCondition; | |||||
| private String message; | |||||
| public void setIf( String c ) | |||||
| { | |||||
| ifCondition = c; | |||||
| } | |||||
| public void setMessage( String value ) | |||||
| { | |||||
| this.message = value; | |||||
| } | |||||
| public void setUnless( String c ) | |||||
| { | |||||
| unlessCondition = c; | |||||
| } | |||||
| /** | |||||
| * Set a multiline message. | |||||
| * | |||||
| * @param msg The feature to be added to the Text attribute | |||||
| */ | |||||
| public void addText( String msg ) | |||||
| throws TaskException | |||||
| { | |||||
| message += project.replaceProperties( msg ); | |||||
| } | |||||
| public void execute() | |||||
| throws TaskException | |||||
| { | |||||
| if( testIfCondition() && testUnlessCondition() ) | |||||
| { | |||||
| if( message != null && message.length() > 0 ) | |||||
| { | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| else | |||||
| { | |||||
| throw new TaskException( "No message" ); | |||||
| } | |||||
| } | |||||
| } | |||||
| private boolean testIfCondition() | |||||
| { | |||||
| if( ifCondition == null || "".equals( ifCondition ) ) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| return project.getProperty( ifCondition ) != null; | |||||
| } | |||||
| private boolean testUnlessCondition() | |||||
| { | |||||
| if( unlessCondition == null || "".equals( unlessCondition ) ) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| return project.getProperty( unlessCondition ) == null; | |||||
| } | |||||
| } | |||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| @@ -31,7 +31,6 @@ import org.apache.tools.ant.types.Environment; | |||||
| */ | */ | ||||
| public class ExecTask extends Task | public class ExecTask extends Task | ||||
| { | { | ||||
| private static String lSep = System.getProperty( "line.separator" ); | private static String lSep = System.getProperty( "line.separator" ); | ||||
| protected boolean failOnError = false; | protected boolean failOnError = false; | ||||
| protected boolean newEnvironment = false; | protected boolean newEnvironment = false; | ||||
| @@ -370,7 +369,7 @@ public class ExecTask extends Task | |||||
| * @param result Description of Parameter | * @param result Description of Parameter | ||||
| */ | */ | ||||
| protected void maybeSetResultPropertyValue( int result ) | protected void maybeSetResultPropertyValue( int result ) | ||||
| throws TaskException | |||||
| throws TaskException | |||||
| { | { | ||||
| String res = Integer.toString( result ); | String res = Integer.toString( result ); | ||||
| if( resultProperty != null ) | if( resultProperty != null ) | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| @@ -239,7 +239,7 @@ public class Execute | |||||
| // Since we "look ahead" before adding, there's one last env var. | // Since we "look ahead" before adding, there's one last env var. | ||||
| procEnvironment.addElement( var ); | procEnvironment.addElement( var ); | ||||
| } | } | ||||
| catch( java.io.IOException exc ) | |||||
| catch( IOException exc ) | |||||
| { | { | ||||
| exc.printStackTrace(); | exc.printStackTrace(); | ||||
| // Just try to see how much we got | // Just try to see how much we got | ||||
| @@ -272,7 +272,7 @@ public class Execute | |||||
| throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); | throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); | ||||
| } | } | ||||
| } | } | ||||
| catch( java.io.IOException exc ) | |||||
| catch( IOException exc ) | |||||
| { | { | ||||
| throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); | throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); | ||||
| } | } | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -1,84 +0,0 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE file. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| import org.apache.myrmidon.api.TaskException; | |||||
| import org.apache.tools.ant.Task; | |||||
| /** | |||||
| * Just exit the active build, giving an additional message if available. | |||||
| * | |||||
| * @author <a href="mailto:nico@seessle.de">Nico Seessle</a> | |||||
| */ | |||||
| public class Exit extends Task | |||||
| { | |||||
| private String ifCondition, unlessCondition; | |||||
| private String message; | |||||
| public void setIf( String c ) | |||||
| { | |||||
| ifCondition = c; | |||||
| } | |||||
| public void setMessage( String value ) | |||||
| { | |||||
| this.message = value; | |||||
| } | |||||
| public void setUnless( String c ) | |||||
| { | |||||
| unlessCondition = c; | |||||
| } | |||||
| /** | |||||
| * Set a multiline message. | |||||
| * | |||||
| * @param msg The feature to be added to the Text attribute | |||||
| */ | |||||
| public void addText( String msg ) | |||||
| throws TaskException | |||||
| { | |||||
| message += project.replaceProperties( msg ); | |||||
| } | |||||
| public void execute() | |||||
| throws TaskException | |||||
| { | |||||
| if( testIfCondition() && testUnlessCondition() ) | |||||
| { | |||||
| if( message != null && message.length() > 0 ) | |||||
| { | |||||
| throw new TaskException( message ); | |||||
| } | |||||
| else | |||||
| { | |||||
| throw new TaskException( "No message" ); | |||||
| } | |||||
| } | |||||
| } | |||||
| private boolean testIfCondition() | |||||
| { | |||||
| if( ifCondition == null || "".equals( ifCondition ) ) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| return project.getProperty( ifCondition ) != null; | |||||
| } | |||||
| private boolean testUnlessCondition() | |||||
| { | |||||
| if( unlessCondition == null || "".equals( unlessCondition ) ) | |||||
| { | |||||
| return true; | |||||
| } | |||||
| return project.getProperty( unlessCondition ) == null; | |||||
| } | |||||
| } | |||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| @@ -31,7 +31,6 @@ import org.apache.tools.ant.types.Environment; | |||||
| */ | */ | ||||
| public class ExecTask extends Task | public class ExecTask extends Task | ||||
| { | { | ||||
| private static String lSep = System.getProperty( "line.separator" ); | private static String lSep = System.getProperty( "line.separator" ); | ||||
| protected boolean failOnError = false; | protected boolean failOnError = false; | ||||
| protected boolean newEnvironment = false; | protected boolean newEnvironment = false; | ||||
| @@ -370,7 +369,7 @@ public class ExecTask extends Task | |||||
| * @param result Description of Parameter | * @param result Description of Parameter | ||||
| */ | */ | ||||
| protected void maybeSetResultPropertyValue( int result ) | protected void maybeSetResultPropertyValue( int result ) | ||||
| throws TaskException | |||||
| throws TaskException | |||||
| { | { | ||||
| String res = Integer.toString( result ); | String res = Integer.toString( result ); | ||||
| if( resultProperty != null ) | if( resultProperty != null ) | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| @@ -239,7 +239,7 @@ public class Execute | |||||
| // Since we "look ahead" before adding, there's one last env var. | // Since we "look ahead" before adding, there's one last env var. | ||||
| procEnvironment.addElement( var ); | procEnvironment.addElement( var ); | ||||
| } | } | ||||
| catch( java.io.IOException exc ) | |||||
| catch( IOException exc ) | |||||
| { | { | ||||
| exc.printStackTrace(); | exc.printStackTrace(); | ||||
| // Just try to see how much we got | // Just try to see how much we got | ||||
| @@ -272,7 +272,7 @@ public class Execute | |||||
| throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); | throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); | ||||
| } | } | ||||
| } | } | ||||
| catch( java.io.IOException exc ) | |||||
| catch( IOException exc ) | |||||
| { | { | ||||
| throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); | throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + exc ); | ||||
| } | } | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -5,7 +5,7 @@ | |||||
| * version 1.1, a copy of which has been included with this distribution in | * version 1.1, a copy of which has been included with this distribution in | ||||
| * the LICENSE file. | * the LICENSE file. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | |||||
| package org.apache.tools.ant.taskdefs.exec; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||