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.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@543682 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-06-02 00:43:15 +00:00
parent 6d69087ae9
commit 6d3984551c
2 changed files with 68 additions and 16 deletions

View File

@ -256,7 +256,7 @@ public class PluginParameterExpressionEvaluatorTest
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()

View File

@ -25,6 +25,8 @@ import org.apache.maven.model.Plugin;
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;
@ -39,6 +41,7 @@ public class BuildOverlay
private final Build build;
private List resources;
private List testResources;
public BuildOverlay( Build build )
@ -47,17 +50,17 @@ public class BuildOverlay
{
this.build = new Build();
this.resources = new ArrayList();
resources = new ArrayList();
this.testResources = new ArrayList();
testResources = new ArrayList();
}
else
{
this.build = build;
this.resources = new ArrayList( build.getResources() );
resources = new ArrayList( build.getResources() );
this.testResources = new ArrayList( build.getTestResources() );
testResources = new ArrayList( build.getTestResources() );
}
}
@ -98,7 +101,17 @@ public class BuildOverlay
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 class BuildOverlay
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 class BuildOverlay
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 class BuildOverlay
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()