ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rees <d.ree...@usa.net>
Subject [PATCH] java task doesn't correctly handle changing drives under Windows
Date Fri, 09 Feb 2001 20:12:05 GMT
<This is a resend. I originally accidently sent it as a reply to
completely different thread so it may have been missed.>

Two patches attached.

Combined they correct Execute (and hence the java task and perhaps
others) when the execute directory's drive is different than the
current directory's drive. Pre-patch the drive change doesn't happen
so the execute runs in a current directory. The first patch fixes it
for NT/2K and the second one fixes it (via a BAT file change) for
9X/ME.

As an example, if your current directory is c:\build and your run
directory is d:\run, previously only a "cd d:\run" was performed and
the active drive was not changed (because of the Windows directory per
drive "feature"). Therefore the execute actually still runs in
c:\build. The patches cause the needed active drive change as well.

dave

PS, May need additional testing on all the Win9X/ME variations. I
don't have all them available to run the tests.

PS II, I assume I don't need to raise a bug if I just supply the patch
- right?


Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
retrieving revision 1.12
diff -u -r1.12 Execute.java
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
2001/01/12 14:08:50	1.12
+++ jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
2001/02/08 02:33:15
@@ -565,13 +565,15 @@
 
             // Use cmd.exe to change to the specified directory
before running
             // the command
-            String[] newcmd = new String[cmd.length+5];
-            newcmd[0] = "cmd";
-            newcmd[1] = "/c";
-            newcmd[2] = "cd";
-            newcmd[3] = workingDir.getAbsolutePath();
-            newcmd[4] = "&&";
-            System.arraycopy(cmd, 0, newcmd, 5, cmd.length);
+	    final int preCmdLength = 6;
+	    String[] newcmd = new String[cmd.length + preCmdLength];
+	    newcmd[0] = "cmd";
+	    newcmd[1] = "/c";
+	    newcmd[2] = "cd";
+   	    newcmd[3] = "/d";
+	    newcmd[4] = workingDir.getAbsolutePath();
+	    newcmd[5] = "&&";
+	    System.arraycopy(cmd, 0, newcmd, preCmdLength,
cmd.length);
             return exec(project, newcmd, env);
         }
     }


Index: jakarta-ant/src/script/antRun.bat
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/script/antRun.bat,v
retrieving revision 1.1
diff -u -r1.1 antRun.bat
--- jakarta-ant/src/script/antRun.bat	2001/01/23 05:10:39	1.1
+++ jakarta-ant/src/script/antRun.bat	2001/02/08 02:33:17
@@ -1,18 +1,20 @@
-@echo off
-
-cd %1
-set ANT_RUN_CMD=%2
-shift
-shift
-
-set PARAMS=
-:loop
-if ""%1 == "" goto runCommand
-set PARAMS=%PARAMS% %1
-shift
-goto loop
-
-:runCommand
-rem echo %ANT_RUN_CMD% %PARAMS%
-%ANT_RUN_CMD% %PARAMS%
-
+@echo off
+
+# Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
+cd %1
+%1\
+set ANT_RUN_CMD=%2
+shift
+shift
+
+set PARAMS=
+:loop
+if ""%1 == "" goto runCommand
+set PARAMS=%PARAMS% %1
+shift
+goto loop
+
+:runCommand
+rem echo %ANT_RUN_CMD% %PARAMS%
+%ANT_RUN_CMD% %PARAMS%
+


---------------------------------------------------------------------
To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ant-dev-help@jakarta.apache.org


Mime
View raw message