Author: bentmann Date: Fri Nov 26 12:17:49 2010 New Revision: 1039327 URL: http://svn.apache.org/viewvc?rev=1039327&view=rev Log: [MNG-4918] MavenProject#clone() doubles active profiles Submitted by: Sebastian Annies
Added: maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml (with props) Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java?rev=1039327&r1=1039326&r2=1039327&view=diff ============================================================================== --- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java (original) +++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java Fri Nov 26 12:17:49 2010 @@ -1407,7 +1407,7 @@ public class MavenProject public void setActiveProfiles( List<Profile> activeProfiles ) { - this.activeProfiles.addAll( activeProfiles ); + this.activeProfiles = activeProfiles; } public List<Profile> getActiveProfiles() Modified: maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java?rev=1039327&r1=1039326&r2=1039327&view=diff ============================================================================== --- maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java (original) +++ maven/maven-3/trunk/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java Fri Nov 26 12:17:49 2010 @@ -27,6 +27,7 @@ import java.util.Map; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; +import org.apache.maven.model.Profile; public class MavenProjectTest extends AbstractMavenProjectTestCase @@ -152,4 +153,23 @@ public class MavenProjectTest MavenProject clonedProject = (MavenProject) projectToClone.clone(); assertNotNull( "clonedProject - distributionManagement", clonedProject.getDistributionManagementArtifactRepository() ); } + + public void testCloneWithActiveProfile() throws Exception + { + + File f = getFileForClasspathResource( "withActiveByDefaultProfile-pom.xml" ); + MavenProject projectToClone = getProject( f ); + List<Profile> activeProfilesOrig = projectToClone.getActiveProfiles(); + + assertEquals( "Expecting 1 active profile", 1, activeProfilesOrig.size() ); + + MavenProject clonedProject = (MavenProject) projectToClone.clone(); + + List<Profile> activeProfilesClone = clonedProject.getActiveProfiles(); + + assertEquals( "Expecting 1 active profile", 1, activeProfilesClone.size() ); + + assertNotSame( "The list of active profiles should have been cloned too but is same", + activeProfilesOrig, activeProfilesClone); + } } Added: maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml?rev=1039327&view=auto ============================================================================== --- maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml (added) +++ maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml Fri Nov 26 12:17:49 2010 @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>maven</groupId> + <artifactId>maven-core</artifactId> + <name>Maven</name> + <version>2.0-SNAPSHOT</version> + + <profiles> + <profile> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <id>test</id> + </profile> + </profiles> +</project> Propchange: maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/maven-3/trunk/maven-core/src/test/resources/withActiveByDefaultProfile-pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision