From 42fbee99105c33002fcbe69609b8a84ab073e48d Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Tue, 6 Sep 2005 18:19:06 +0000 Subject: [PATCH] clone bugfix git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@279052 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/project/ModelUtils.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java index 1d81ee081b..27d14ffbc3 100644 --- a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java +++ b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java @@ -18,6 +18,7 @@ package org.apache.maven.project; import org.apache.maven.model.Goal; import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; 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 Model newModel = new Model(); 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.setArtifactId( model.getArtifactId() ); + newModel.setModules( cloneModules( model.getModules() ) ); + assembler.assembleModelInheritance( newModel, model ); 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 ) { List repositories = new ArrayList();