Author: jdcasey
Date: Fri Jun  1 17:43:15 2007
New Revision: 543682

URL: http://svn.apache.org/viewvc?view=rev&rev=543682
Log:
OPEN - issue MNG-2671: Parent/modules relative file path compression 
http://jira.codehaus.org/browse/MNG-2671

Applied, with small changes so it will not swallow exceptions. If this causes a 
problem with broken symlinks, we can address that later.

Modified:
    
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
    
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java

Modified: 
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java?view=diff&rev=543682&r1=543681&r2=543682
==============================================================================
--- 
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
 (original)
+++ 
maven/components/trunk/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java
 Fri Jun  1 17:43:15 2007
@@ -256,7 +256,7 @@
 
         Object value = expressionEvaluator.evaluate( 
"${project.build.directory}/${project.build.finalName}" );
 
-        assertEquals( "expected-directory/expected-finalName", value );
+        assertEquals( new File( "expected-directory/expected-finalName" 
).getCanonicalPath(), value );
     }
 
     public void testShouldExtractPluginArtifacts()

Modified: 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java?view=diff&rev=543682&r1=543681&r2=543682
==============================================================================
--- 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java
 (original)
+++ 
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/overlay/BuildOverlay.java
 Fri Jun  1 17:43:15 2007
@@ -25,6 +25,8 @@
 import org.apache.maven.model.PluginManagement;
 import org.apache.maven.model.Resource;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -35,10 +37,11 @@
 public class BuildOverlay
     extends Build
 {
-    
+
     private final Build build;
-    
+
     private List resources;
+
     private List testResources;
 
     public BuildOverlay( Build build )
@@ -46,18 +49,18 @@
         if ( build == null )
         {
             this.build = new Build();
-            
-            this.resources = new ArrayList();
-            
-            this.testResources = new ArrayList();
+
+            resources = new ArrayList();
+
+            testResources = new ArrayList();
         }
         else
         {
             this.build = build;
-            
-            this.resources = new ArrayList( build.getResources() );
-            
-            this.testResources = new ArrayList( build.getTestResources() );
+
+            resources = new ArrayList( build.getResources() );
+
+            testResources = new ArrayList( build.getTestResources() );
         }
     }
 
@@ -98,7 +101,17 @@
 
     public String getDirectory()
     {
-        return build.getDirectory();
+        String path = build.getDirectory();
+        File file = new File( build.getDirectory() );
+        try
+        {
+            path = file.getCanonicalPath();
+        }
+        catch ( IOException e )
+        {
+            handleCanonicalException( path, e );
+        }
+        return path;
     }
 
     public List getExtensions()
@@ -113,7 +126,17 @@
 
     public String getOutputDirectory()
     {
-        return build.getOutputDirectory();
+        String path = build.getDirectory();
+        File file = new File( build.getOutputDirectory() );
+        try
+        {
+            path = file.getCanonicalPath();
+        }
+        catch ( IOException e )
+        {
+            handleCanonicalException( path, e );
+        }
+        return path;
     }
 
     public PluginManagement getPluginManagement()
@@ -138,7 +161,26 @@
 
     public String getScriptSourceDirectory()
     {
-        return build.getScriptSourceDirectory();
+        String path = build.getDirectory();
+        File file = new File( build.getScriptSourceDirectory() );
+        try
+        {
+            path = file.getCanonicalPath();
+        }
+        catch ( IOException e )
+        {
+            handleCanonicalException( path, e );
+        }
+        return path;
+    }
+
+    private void handleCanonicalException( String path, IOException e )
+    {
+        IllegalStateException error = new IllegalStateException( "Cannot 
compute canonical path for: " + path
+                                                                 + ". Reason: 
" + e.getMessage() );
+        error.initCause( e );
+
+        throw error;
     }
 
     public String getSourceDirectory()
@@ -158,7 +200,17 @@
 
     public String getTestSourceDirectory()
     {
-        return build.getTestSourceDirectory();
+        String path = build.getDirectory();
+        File file = new File( build.getTestSourceDirectory() );
+        try
+        {
+            path = file.getCanonicalPath();
+        }
+        catch ( IOException e )
+        {
+            handleCanonicalException( path, e );
+        }
+        return path;
     }
 
     public int hashCode()
@@ -258,7 +310,7 @@
 
     public void addFilter( String string )
     {
-        build.addFilter( string );   
+        build.addFilter( string );
     } //-- void addFilter(String)
 
     public List getFilters()


Reply via email to