From a8ce74df45192ff3f0e8ae6e1aab83f5d255f9c1 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 20 Feb 2011 15:34:42 +0000 Subject: [PATCH] [MNG-5000] [regression] child distributionManagment.site.url not correct in a flat directory layout when child's artifactId doesn't match its module name git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1072613 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultInheritanceAssembler.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java index da0673af74..a66be04dea 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java @@ -19,6 +19,7 @@ * under the License. */ +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -74,7 +75,19 @@ private String getChildPathAdjustment( Model child, Model parent ) if ( parent != null ) { - String childArtifactId = child.getArtifactId(); + String childName = child.getArtifactId(); + + /* + * This logic exists only for the sake of backward-compat with 2.x (MNG-5000). In generally, it is wrong to + * base URL inheritance on the project directory names as this information is unavailable for POMs in the + * repository. In other words, projects where artifactId != projectDirName will see different effective URLs + * depending on how the POM was constructed. + */ + File childDirectory = child.getProjectDirectory(); + if ( childDirectory != null ) + { + childName = childDirectory.getName(); + } for ( String module : parent.getModules() ) { @@ -95,7 +108,7 @@ private String getChildPathAdjustment( Model child, Model parent ) moduleName = moduleName.substring( lastSlash + 1 ); - if ( moduleName.equals( childArtifactId ) && lastSlash >= 0 ) + if ( moduleName.equals( childName ) && lastSlash >= 0 ) { adjustment = module.substring( 0, lastSlash ); break;