clone bugfix

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@279052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-06 18:19:06 +00:00
parent 8c97337f8b
commit 42fbee9910
1 changed files with 30 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package org.apache.maven.project;
import org.apache.maven.model.Goal; import org.apache.maven.model.Goal;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginExecution;
@ -459,12 +460,40 @@ public final class ModelUtils
// TODO: would be nice for the modello:java code to generate this as a copy constructor // TODO: would be nice for the modello:java code to generate this as a copy constructor
Model newModel = new Model(); Model newModel = new Model();
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler(); ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
assembler.assembleModelInheritance( newModel, model ); newModel.setModelVersion( model.getModelVersion() );
newModel.setName( model.getName() );
newModel.setParent( cloneParent( model.getParent() ) );
newModel.setVersion( model.getVersion() ); newModel.setVersion( model.getVersion() );
newModel.setArtifactId( model.getArtifactId() ); newModel.setArtifactId( model.getArtifactId() );
newModel.setModules( cloneModules( model.getModules() ) );
assembler.assembleModelInheritance( newModel, model );
return newModel; return newModel;
} }
private static List cloneModules( List modules )
{
if ( modules == null )
{
return modules;
}
return new ArrayList( modules );
}
private static Parent cloneParent( Parent parent )
{
if ( parent == null )
{
return parent;
}
Parent newParent = new Parent();
newParent.setArtifactId( parent.getArtifactId() );
newParent.setGroupId( parent.getGroupId() );
newParent.setRelativePath( parent.getRelativePath() );
newParent.setVersion( parent.getVersion() );
return newParent;
}
public static List mergeRepositoryLists( List dominant, List recessive ) public static List mergeRepositoryLists( List dominant, List recessive )
{ {
List repositories = new ArrayList(); List repositories = new ArrayList();