continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r563650 - /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
Date Tue, 07 Aug 2007 20:41:50 GMT
Author: evenisse
Date: Tue Aug  7 13:41:50 2007
New Revision: 563650

URL: http://svn.apache.org/viewvc?view=rev&rev=563650
Log:
[CONTINUUM-1303] use relative path for project working directory so global working directory
changes will take effect

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java?view=diff&rev=563650&r1=563649&r2=563650
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/DefaultWorkingDirectoryService.java
Tue Aug  7 13:41:50 2007
@@ -52,18 +52,34 @@
 //        return new File( projectGroup.getWorkingDirectory(),
 //                         project.getPath() );
 
-        File workDir;
         if ( project.getWorkingDirectory() == null )
         {
-            workDir = new File( configurationService.getWorkingDirectory(), Integer.toString(
project.getId() ) );
+            project.setWorkingDirectory( Integer.toString( project.getId() ) );
+        }
+
+        File workDir;
+        File projectWorkingDirectory = new File( project.getWorkingDirectory() );
+        if ( projectWorkingDirectory.isAbsolute() )
+        {
+            // clean the project working directory path if it's a subdirectory of the global
working directory
+            if ( projectWorkingDirectory.getAbsolutePath().startsWith(
+                configurationService.getWorkingDirectory().getAbsolutePath() ) )
+            {
+                String pwd = projectWorkingDirectory.getAbsolutePath().substring(
+                    configurationService.getWorkingDirectory().getAbsolutePath().length()
);
+                if ( pwd.startsWith( "/" ) || pwd.startsWith( "\\" ) )
+                {
+                    pwd = pwd.substring( 1 );
+                }
+                project.setWorkingDirectory( pwd );
+            }
 
-            project.setWorkingDirectory( workDir.getAbsolutePath() );
+            workDir = projectWorkingDirectory;
         }
         else
         {
-            workDir = new File( project.getWorkingDirectory() );
+            workDir = new File( configurationService.getWorkingDirectory(), project.getWorkingDirectory()
);
         }
-
         return workDir;
     }
 }



Mime
View raw message