diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java index cb7a781d22..7675f88196 100644 --- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java +++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java @@ -80,6 +80,7 @@ import java.util.Stack; * */ public class MavenProject + implements Cloneable { public static final String EMPTY_PROJECT_GROUP_ID = "unknown"; @@ -169,10 +170,14 @@ public class MavenProject } /** - * @deprecated use {@link #clone()} + * @deprecated use {@link #clone()} so subclasses can provide a copy of the same class */ public MavenProject( MavenProject project ) { + deepCopy( project ); + } + + private final void deepCopy(MavenProject project){ // disown the parent // copy fields @@ -1825,11 +1830,15 @@ public class MavenProject } /** + * @throws CloneNotSupportedException * @since 2.0.9 */ public Object clone() + throws CloneNotSupportedException { - return new MavenProject( this ); + MavenProject clone = (MavenProject) super.clone(); + clone.deepCopy( this ); + return clone; } }