From 68c083042314aa37745ca1b84c662b084694e180 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 6 Jan 2002 02:07:06 +0000 Subject: [PATCH] Move runCommand into this class git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270574 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/optional/javacc/JavaCC.java | 29 +++++++++++++++++-- .../ant/taskdefs/optional/javacc/JavaCC.java | 29 +++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java index 69a4821e6..ba2a7cd91 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java @@ -8,12 +8,14 @@ package org.apache.tools.ant.taskdefs.optional.javacc; import java.io.File; +import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.exec.Execute; +import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.types.Argument; +import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; @@ -224,7 +226,7 @@ public class JavaCC extends Task { throw new TaskException( "Javacchome not set." ); } - final Path classpath = cmdl.createClasspath( getProject() ); + final Path classpath = cmdl.createClasspath(); classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + "/JavaCC.zip" ); classpath.addJavaRuntime(); @@ -233,7 +235,28 @@ public class JavaCC extends Task arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); - Execute.runCommand( this, cmdl.getCommandline() ); + runCommand( cmdl.getCommandline() ); + } + + private void runCommand( final String[] cmdline ) + throws TaskException + { + try + { + getLogger().debug( Commandline.toString( cmdline ) ); + final Execute2 exe = new Execute2(); + setupLogger( exe ); + exe.setCommandline( cmdline ); + int retval = exe.execute(); + if( retval != 0 ) + { + throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); + } + } + catch( final IOException ioe ) + { + throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + ioe ); + } } /** diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java index 69a4821e6..ba2a7cd91 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java @@ -8,12 +8,14 @@ package org.apache.tools.ant.taskdefs.optional.javacc; import java.io.File; +import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; import org.apache.myrmidon.api.TaskException; import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.exec.Execute; +import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.types.Argument; +import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; @@ -224,7 +226,7 @@ public class JavaCC extends Task { throw new TaskException( "Javacchome not set." ); } - final Path classpath = cmdl.createClasspath( getProject() ); + final Path classpath = cmdl.createClasspath(); classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + "/JavaCC.zip" ); classpath.addJavaRuntime(); @@ -233,7 +235,28 @@ public class JavaCC extends Task arg.setValue( "-mx140M" ); arg.setValue( "-Dinstall.root=" + javaccHome.getAbsolutePath() ); - Execute.runCommand( this, cmdl.getCommandline() ); + runCommand( cmdl.getCommandline() ); + } + + private void runCommand( final String[] cmdline ) + throws TaskException + { + try + { + getLogger().debug( Commandline.toString( cmdline ) ); + final Execute2 exe = new Execute2(); + setupLogger( exe ); + exe.setCommandline( cmdline ); + int retval = exe.execute(); + if( retval != 0 ) + { + throw new TaskException( cmdline[ 0 ] + " failed with return code " + retval ); + } + } + catch( final IOException ioe ) + { + throw new TaskException( "Could not launch " + cmdline[ 0 ] + ": " + ioe ); + } } /**