Browse Source

Mac patches to Execute (regarding working directory).

Submitted by:	beard@netscape.com (Patrick Beard)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267881 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
29cf33f78f
3 changed files with 29 additions and 4 deletions
  1. +8
    -2
      WHATSNEW
  2. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/Exec.java
  3. +18
    -2
      src/main/org/apache/tools/ant/taskdefs/Execute.java

+ 8
- 2
WHATSNEW View File

@@ -19,8 +19,10 @@ org.apache.tools.ant to org.apache.tools.ant.types.
Other changes:
--------------

* New tasks: sql, junit, mparse, execon. All except sql pending
documentation, most of them pending review.
* New tasks: sql, genkey, cab.

* New tasks junit, mparse, execon. All pending documentation, most of
them pending review.

* <java> uses ClassLoader of its own in no-fork mode if a classpath is
specified.
@@ -55,3 +57,7 @@ respect to the Project's basedir.

* Project didn't interpret the basedir attribute correctly in all
cases.

* Nested <src> in <javac> caused NullPointerException.

* Corrupt Zip- and Jar-files ar now deleted if the task fails.

+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/Exec.java View File

@@ -62,6 +62,9 @@ import java.io.*;
*
* @author duncan@x180.com
* @author rubys@us.ibm.com
*
* @deprected Instead of using this class, please extend ExecTask or
* delegate to Execute.
*/
public class Exec extends Task {
private String os;


+ 18
- 2
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -127,7 +127,8 @@ public class Execute {
String[] commandLine = cmdl;

if (workingDirectory != null &&
!antWorkingDirectory.equals(workingDirectory.getAbsolutePath())) {
!antWorkingDirectory.equals(workingDirectory.getAbsolutePath()) &&
!myos.equals("Mac OS")) {

if (myos.toLowerCase().indexOf("windows") >= 0 &&
(myos.toLowerCase().indexOf("nt") >= 0 ||
@@ -200,6 +201,9 @@ public class Execute {
* @param project the current project.
*/
public void setAntRun(Project project) throws BuildException {
if (myos.equals("Mac OS"))
return;

String ant = project.getProperty("ant.home");
if (ant == null) {
throw new BuildException("Property 'ant.home' not found");
@@ -240,7 +244,19 @@ public class Execute {


protected Process exec() throws IOException {
return Runtime.getRuntime().exec(getCommandline(), getEnvironment());
String userDir = System.getProperty("user.dir");
try {
if (myos.equals("Mac OS") && workingDirectory != null) {
System.getProperties().put("user.dir",
workingDirectory.getAbsolutePath());
}

return Runtime.getRuntime().exec(getCommandline(), getEnvironment());
} finally {
if (myos.equals("Mac OS") && workingDirectory != null) {
System.getProperties().put("user.dir", userDir);
}
}
}

protected void waitFor(Process process) {


Loading…
Cancel
Save