At 10:56 AM +0200 7/31/2000, Stefan Bodewig wrote:
>Hi Patrick,
>
>nice to see somebody is using Ant on the Mac. I was starting to wonder
>if all the assumptions we made actually worked out there as well.
>
>>>>>> "PB" == Patrick Beard <[EMAIL PROTECTED]> writes:
>
> PB> Here are slightly cleaner patches for the Mac
>
>I don't see how this is expected to work, could you please help me out
>a little.
>
>When invoking <exec> you get to the ExecTask class not Exec, your
>changes to Exec only effect those classes that extend Exec - and I'm
>hoping to get all of them converted to not do so during the next two
>weeks.
>
>If I apply your patches <exec> won't change the directory at all
>(under MacOS that is), and user.dir won't get changed either. Actually
>we'd want to change it back after the exec so we'd need further
>modifications to Execute anyway, right?
>
>The check you propose for Exec !dir.equals(project.resolveFile("."))
>will only check whether dir is the project's base dir. basedir and the
>current working directory of Ant could be different though.

Here's a slightly different set of patches. This addresses restoring "user.dir" 
after calling Runtime.exec().

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.2
diff -c -2 -r1.2 Execute.java
*** jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java     
2000/07/25 12:03:26     1.2
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java     
2000/08/02 16:35:16
***************
*** 118,123 ****
 
          if (workingDirectory != null &&
!             !antWorkingDirectory.equals(workingDirectory.getAbsolutePath())) {
!
              if (myos.toLowerCase().indexOf("windows") >= 0 &&
                  myos.toLowerCase().indexOf("nt") >= 0) {
--- 118,123 ----
 
          if (workingDirectory != null &&
!             !antWorkingDirectory.equals(workingDirectory.getAbsolutePath()) &&
!             !myos.equals("Mac OS")) {
              if (myos.toLowerCase().indexOf("windows") >= 0 &&
                  myos.toLowerCase().indexOf("nt") >= 0) {
***************
*** 130,134 ****
                  commandLine[4] = "&&";
                  System.arraycopy(cmdl, 0, commandLine, 5, cmdl.length);
-
              } else {
                  commandLine = new String[cmdl.length+2];
--- 130,133 ----
***************
*** 190,193 ****
--- 189,195 ----
       */
      public void setAntRun(Project project) throws BuildException {
+       if (myos.equals("Mac OS"))
+               return;
+       
          String ant = project.getProperty("ant.home");
          if (ant == null) {

Index: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java,v
retrieving revision 1.15
diff -c -2 -r1.15 Exec.java
*** jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java        
2000/07/15 06:31:42     1.15
--- jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java        
2000/08/02 16:35:15
***************
*** 93,98 ****
          // default directory to the project's base directory
          if (dir == null) dir = project.getBaseDir();
 
!         if (myos.toLowerCase().indexOf("windows") >= 0) {
              if (!dir.equals(project.resolveFile("."))) {
                  if (myos.toLowerCase().indexOf("nt") >= 0) {
--- 93,105 ----
          // default directory to the project's base directory
          if (dir == null) dir = project.getBaseDir();
+         String userDir = null;
 
!               if (myos.equals("Mac OS")) {
!                       // MRJ tracks "user.dir" property for the current 
working directory.
!                       if (!dir.equals(project.resolveFile("."))) {
!                               userDir = System.getProperty("user.dir");
!                               System.getProperties().put("user.dir", dir);
!                       }
!         } else if (myos.toLowerCase().indexOf("windows") >= 0) {
              if (!dir.equals(project.resolveFile("."))) {
                  if (myos.toLowerCase().indexOf("nt") >= 0) {
***************
*** 123,126 ****
--- 130,136 ----
              // exec command on system runtime
              Process proc = Runtime.getRuntime().exec(command);
+            
+             // restore user directory, if it was changed.
+             if (userDir != null) System.getProperties().put("user.dir", dir);
 
              if( out!=null )  {
-- 

// Patrick C. Beard
// Java Runtime Enthusiast -- "Will invoke interfaces for food."
// mailto:[EMAIL PROTECTED]

Reply via email to