From 5fc021b758b1e224795db6b6abb850efcb4d51fd Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Sat, 15 Jul 2000 06:31:42 +0000 Subject: [PATCH] Restore antRun.bat for Win9x users. This should allow the exec task to execute on Win9x. I have changed Glen's patch to test for platfrom != NT rather than == 98 so it will support 95. NOTE: There is an important limitation. Only 9 arguments can be passed to the command being exec'ed when the antRun.bat file is used. This should only occur when the directory is not . and the platform is not NT. This was the original reason this was changed (and antRun.bat) deleted. Submitted by: Glen Stampoultzis git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267789 13f79535-47bb-0310-9956-ffa450edef68 --- build.bat | 6 +++--- src/bin/antRun.bat | 9 +++++++++ .../org/apache/tools/ant/taskdefs/Exec.java | 17 ++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100755 src/bin/antRun.bat diff --git a/build.bat b/build.bat index 8f6f856ed..9beea3cb3 100755 --- a/build.bat +++ b/build.bat @@ -2,10 +2,10 @@ set REALANTHOME=%ANT_HOME% set ANT_HOME=. -if not exist lib\ant.jar call bootstrap.bat -if not exist bin\ant.bat call bootstrap.bat -if not exist bin\lcp.bat call bootstrap.bat +if exist lib\ant.jar if exist bin\ant.bat if exist bin\lcp.bat if exist bin\antRun.bat goto runAnt +call bootstrap.bat +:runAnt set ANT_INSTALL= if not "%REALANTHOME%" == "" set ANT_INSTALL=-Dant.install %REALANTHOME% call .\bin\ant.bat %ANT_INSTALL% %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/src/bin/antRun.bat b/src/bin/antRun.bat new file mode 100755 index 000000000..08e03519c --- /dev/null +++ b/src/bin/antRun.bat @@ -0,0 +1,9 @@ +@echo off + +cd %1 +set ANT_RUN_CMD=%2 +shift +shift + +%ANT_RUN_CMD% %1 %2 %3 %4 %5 %6 %7 %8 %9 + diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java index 7e1c69909..a07ed3906 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Exec.java +++ b/src/main/org/apache/tools/ant/taskdefs/Exec.java @@ -63,7 +63,6 @@ import java.io.*; * @author duncan@x180.com * @author rubys@us.ibm.com */ - public class Exec extends Task { private String os; private String out; @@ -95,8 +94,20 @@ public class Exec extends Task { if (dir == null) dir = project.getBaseDir(); if (myos.toLowerCase().indexOf("windows") >= 0) { - if (!dir.equals(project.resolveFile("."))) - command = "cmd /c cd " + dir + " && " + command; + if (!dir.equals(project.resolveFile("."))) { + if (myos.toLowerCase().indexOf("nt") >= 0) { + command = "cmd /c cd " + dir + " && " + command; + } + else { + String ant = project.getProperty("ant.home"); + if (ant == null) { + throw new BuildException("Property 'ant.home' not found", location); + } + + String antRun = project.resolveFile(ant + "/bin/antRun.bat").toString(); + command = antRun + " " + dir + " " + command; + } + } } else { String ant = project.getProperty("ant.home"); if (ant == null) throw new BuildException("Property 'ant.home' not found", location);