fix issues with cloning appending extra paths

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@279237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-07 04:08:30 +00:00
parent aa34ddef37
commit 434ec90fa6
3 changed files with 34 additions and 14 deletions

View File

@ -466,7 +466,7 @@ public final class ModelUtils
newModel.setVersion( model.getVersion() ); newModel.setVersion( model.getVersion() );
newModel.setArtifactId( model.getArtifactId() ); newModel.setArtifactId( model.getArtifactId() );
newModel.setModules( cloneModules( model.getModules() ) ); newModel.setModules( cloneModules( model.getModules() ) );
assembler.assembleModelInheritance( newModel, model ); assembler.copyModel( newModel, model );
return newModel; return newModel;
} }

View File

@ -46,7 +46,17 @@ import java.util.TreeMap;
public class DefaultModelInheritanceAssembler public class DefaultModelInheritanceAssembler
implements ModelInheritanceAssembler implements ModelInheritanceAssembler
{ {
public void copyModel( Model dest, Model source )
{
assembleModelInheritance( dest, source, false );
}
public void assembleModelInheritance( Model child, Model parent ) public void assembleModelInheritance( Model child, Model parent )
{
assembleModelInheritance( child, parent, true );
}
private void assembleModelInheritance( Model child, Model parent, boolean appendPaths )
{ {
// cannot inherit from null parent. // cannot inherit from null parent.
if ( parent == null ) if ( parent == null )
@ -83,7 +93,7 @@ public class DefaultModelInheritanceAssembler
{ {
if ( parent.getUrl() != null ) if ( parent.getUrl() != null )
{ {
child.setUrl( appendPath( parent.getUrl(), child.getArtifactId() ) ); child.setUrl( appendPath( parent.getUrl(), child.getArtifactId(), appendPaths ) );
} }
else else
{ {
@ -95,7 +105,7 @@ public class DefaultModelInheritanceAssembler
// Distribution // Distribution
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
assembleDistributionInheritence( child, parent ); assembleDistributionInheritence( child, parent, appendPaths );
// issueManagement // issueManagement
if ( child.getIssueManagement() == null ) if ( child.getIssueManagement() == null )
@ -116,7 +126,7 @@ public class DefaultModelInheritanceAssembler
} }
// Scm // Scm
assembleScmInheritance( child, parent ); assembleScmInheritance( child, parent, appendPaths );
// ciManagement // ciManagement
if ( child.getCiManagement() == null ) if ( child.getCiManagement() == null )
@ -382,7 +392,7 @@ public class DefaultModelInheritanceAssembler
} }
private void assembleScmInheritance( Model child, Model parent ) private void assembleScmInheritance( Model child, Model parent, boolean appendPaths )
{ {
if ( parent.getScm() != null ) if ( parent.getScm() != null )
{ {
@ -399,24 +409,25 @@ public class DefaultModelInheritanceAssembler
if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
{ {
childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId() ) ); childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), appendPaths ) );
} }
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
{ {
childScm childScm
.setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId() ) ); .setDeveloperConnection(
appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), appendPaths ) );
} }
if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
{ {
childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId() ) ); childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), appendPaths ) );
} }
} }
} }
private void assembleDistributionInheritence( Model child, Model parent ) private void assembleDistributionInheritence( Model child, Model parent, boolean appendPaths )
{ {
if ( parent.getDistributionManagement() != null ) if ( parent.getDistributionManagement() != null )
{ {
@ -447,7 +458,7 @@ public class DefaultModelInheritanceAssembler
if ( site.getUrl() != null ) if ( site.getUrl() != null )
{ {
site.setUrl( appendPath( site.getUrl(), child.getArtifactId() ) ); site.setUrl( appendPath( site.getUrl(), child.getArtifactId(), appendPaths ) );
} }
} }
} }
@ -486,7 +497,9 @@ public class DefaultModelInheritanceAssembler
} }
} }
private String appendPath( String url, String path ) private String appendPath( String url, String path, boolean appendPaths )
{
if ( appendPaths )
{ {
if ( url.endsWith( "/" ) ) if ( url.endsWith( "/" ) )
{ {
@ -497,6 +510,11 @@ public class DefaultModelInheritanceAssembler
return url + "/" + path; return url + "/" + path;
} }
} }
else
{
return url;
}
}
private void mergeExtensionLists( Build childBuild, Build parentBuild ) private void mergeExtensionLists( Build childBuild, Build parentBuild )
{ {

View File

@ -27,4 +27,6 @@ public interface ModelInheritanceAssembler
String ROLE = ModelInheritanceAssembler.class.getName(); String ROLE = ModelInheritanceAssembler.class.getName();
void assembleModelInheritance( Model child, Model parent ); void assembleModelInheritance( Model child, Model parent );
void copyModel( Model dest, Model source );
} }