From fbc5bf92d015857358e37520ab077ba59e569de6 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Fri, 13 Mar 2009 19:25:02 +0000 Subject: [PATCH] o Fixed missing basedir alignment git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@753361 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/path/DefaultPathTranslator.java | 15 ++++++++ .../apache/maven/project/MavenProject.java | 35 +++++++++++-------- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java b/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java index 3621d5b29f..3b9f82152d 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java +++ b/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java @@ -26,6 +26,7 @@ import java.util.List; import org.apache.maven.model.Build; import org.apache.maven.model.Model; +import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; import org.codehaus.plexus.component.annotations.Component; @@ -77,6 +78,13 @@ public class DefaultPathTranslator build.setTestOutputDirectory( alignToBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } + + Reporting reporting = model.getReporting(); + + if ( reporting != null ) + { + reporting.setOutputDirectory( alignToBaseDirectory( reporting.getOutputDirectory(), basedir ) ); + } } public String alignToBaseDirectory( String path, File basedir ) @@ -204,6 +212,13 @@ public class DefaultPathTranslator build.setTestOutputDirectory( unalignFromBaseDirectory( build.getTestOutputDirectory(), basedir ) ); } + + Reporting reporting = model.getReporting(); + + if ( reporting != null ) + { + reporting.setOutputDirectory( unalignFromBaseDirectory( reporting.getOutputDirectory(), basedir ) ); + } } public String unalignFromBaseDirectory( String directory, File basedir ) diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java index e3640e6496..6adc6fe29e 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java @@ -422,21 +422,36 @@ public class MavenProject // Test and compile sourceroots. // ---------------------------------------------------------------------- - public void addCompileSourceRoot( String path ) + private void addPath( List paths, String path ) { if ( path != null ) { path = path.trim(); - if ( path.length() != 0 ) + if ( path.length() > 0 ) { - if ( !getCompileSourceRoots().contains( path ) ) + File file = new File( path ); + if ( file.isAbsolute() ) { - getCompileSourceRoots().add( path ); + path = file.getAbsolutePath(); + } + else + { + path = new File( getBasedir(), path ).getAbsolutePath(); + } + + if ( !paths.contains( path ) ) + { + paths.add( path ); } } } } + public void addCompileSourceRoot( String path ) + { + addPath( getCompileSourceRoots(), path ); + } + public void addScriptSourceRoot( String path ) { if ( path != null ) @@ -454,17 +469,7 @@ public class MavenProject public void addTestCompileSourceRoot( String path ) { - if ( path != null ) - { - path = path.trim(); - if ( path.length() != 0 ) - { - if ( !getTestCompileSourceRoots().contains( path ) ) - { - getTestCompileSourceRoots().add( path ); - } - } - } + addPath( getTestCompileSourceRoots(), path ); } public List getCompileSourceRoots()