[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
This commit is contained in:
Benjamin Bentmann 2011-02-20 15:34:42 +00:00
parent 88349565ec
commit a8ce74df45
1 changed files with 15 additions and 2 deletions

View File

@ -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;