You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/12/21 14:20:17 UTC
cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers ScriptCommandLauncher.java PerlCommandLauncher.java
donaldp 01/12/21 05:20:17
Added: proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers
ScriptCommandLauncher.java PerlCommandLauncher.java
Log:
Converted the old remaining useful script based CommandLaunchers to new setup. There is no need to extend ProxyCommandLauncher as it did not offer any benefit (because the 2 arg version of Runtime.exec was always called)
Revision Changes Path
1.1 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/ScriptCommandLauncher.java
Index: ScriptCommandLauncher.java
===================================================================
/*
* 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.txt file.
*/
package org.apache.myrmidon.framework.exec.launchers;
import java.io.IOException;
import java.io.File;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.exec.CommandLauncher;
import org.apache.myrmidon.framework.exec.ExecMetaData;
import org.apache.avalon.excalibur.io.FileUtil;
/**
* A command launcher that uses an auxiliary script to launch commands in
* directories other than the current working directory.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
* @version $Revision: 1.1 $ $Date: 2001/12/21 13:20:17 $
*/
public class ScriptCommandLauncher
implements CommandLauncher
{
private String m_script;
public ScriptCommandLauncher( final String script )
{
m_script = script;
}
/**
* Launches the given command in a new process using cmd.exe to
* set the working directory.
*/
public Process exec( final ExecMetaData metaData )
throws IOException, TaskException
{
final File homeDir = ExecUtil.getAntHomeDirectory();
final String script = FileUtil.resolveFile( homeDir, m_script ).toString();
// Build the command
final String[] prefix = new String[ 2 ];
prefix[ 0 ] = script;
prefix[ 1 ] = metaData.getWorkingDirectory().getCanonicalPath();
final ExecMetaData newMetaData = ExecUtil.prepend( metaData, prefix );
return Runtime.getRuntime().
exec( newMetaData.getCommand(), newMetaData.getEnvironment() );
}
}
1.1 jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/PerlCommandLauncher.java
Index: PerlCommandLauncher.java
===================================================================
/*
* 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.txt file.
*/
package org.apache.myrmidon.framework.exec.launchers;
import java.io.IOException;
import java.io.File;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.exec.CommandLauncher;
import org.apache.myrmidon.framework.exec.ExecMetaData;
import org.apache.avalon.excalibur.io.FileUtil;
/**
* A command launcher that uses an auxiliary script to launch commands in
* directories other than the current working directory.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
* @version $Revision: 1.1 $ $Date: 2001/12/21 13:20:17 $
*/
public class PerlCommandLauncher
implements CommandLauncher
{
private String m_script;
public PerlCommandLauncher( final String script )
{
m_script = script;
}
/**
* Launches the given command in a new process using cmd.exe to
* set the working directory.
*/
public Process exec( final ExecMetaData metaData )
throws IOException, TaskException
{
final File homeDir = ExecUtil.getAntHomeDirectory();
final String script = FileUtil.resolveFile( homeDir, m_script ).toString();
// Build the command
final String[] prefix = new String[ 3 ];
prefix[ 0 ] = "perl";
prefix[ 1 ] = script;
prefix[ 2 ] = metaData.getWorkingDirectory().getCanonicalPath();
final ExecMetaData newMetaData = ExecUtil.prepend( metaData, prefix );
return Runtime.getRuntime().
exec( newMetaData.getCommand(), newMetaData.getEnvironment() );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>