Browse Source

Added slightly modified version of Execute.

Script adds support for Netware in Execute. In the case of a non JVM supported execute (ie when changing dirs pre1.3) will call out to a perl script.

Submitted by: "Jeff Tulley" <JTULLEY@novell.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269916 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
37e1a98039
1 changed files with 64 additions and 0 deletions
  1. +64
    -0
      src/main/org/apache/tools/ant/taskdefs/Execute.java

+ 64
- 0
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -145,6 +145,20 @@ public class Execute {
shellLauncher = new ScriptCommandLauncher("bin/antRun.bat", baseLauncher);
}
}
else if ( (new Os("netware")).eval() ) {
// NetWare. Need to determine which JDK we're running in
CommandLauncher baseLauncher;
if ( System.getProperty("java.version").startsWith("1.1") ) {
// JDK 1.1
baseLauncher = new Java11CommandLauncher();
}
else {
// JDK 1.2
baseLauncher = new CommandLauncher();
}

shellLauncher = new PerlScriptCommandLauncher("bin/antRun.pl", baseLauncher);
}
else {
// Generic
shellLauncher = new ScriptCommandLauncher("bin/antRun", new CommandLauncher());
@@ -725,4 +739,54 @@ public class Execute {

private String _script;
}

/**
* A command launcher that uses an auxiliary perl script to launch commands
* in directories other than the current working directory.
*/
private static class PerlScriptCommandLauncher extends CommandLauncherProxy
{
PerlScriptCommandLauncher(String script, CommandLauncher launcher)
{
super(launcher);
_script = script;
}

/**
* Launches the given command in a new process, in the given working
* directory
*/
public Process exec(Project project, String[] cmd, String[] env, File workingDir) throws IOException
{
if ( project == null ) {
if ( workingDir == null ) {
return exec(project, cmd, env);
}
throw new IOException("Cannot locate antRun script: No project provided");
}
// Locate the auxiliary script
String antHome = project.getProperty("ant.home");
if ( antHome == null ) {
throw new IOException("Cannot locate antRun script: Property 'ant.home' not found");
}
String antRun = project.resolveFile(antHome + File.separator + _script).toString();

// Build the command
File commandDir = workingDir;
if ( workingDir == null && project != null ) {
commandDir = project.getBaseDir();
}

String[] newcmd = new String[cmd.length + 3];
newcmd[0] = "perl";
newcmd[1] = antRun;
newcmd[2] = commandDir.getAbsolutePath();
System.arraycopy(cmd, 0, newcmd, 3, cmd.length);
return exec(project, newcmd, env);
}

private String _script;
}
}

Loading…
Cancel
Save