From 57568aa9842a54b4faebaef24c161b47c359eed5 Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Tue, 7 Apr 2009 13:28:02 +0000 Subject: [PATCH] [MNG-3545] overridden if profile is activebyDefault. Fixed and added unit test. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@762767 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/profiles/DefaultProfileManager.java | 4 +-- .../maven/project/PomConstructionTest.java | 11 +++++- .../profile-default-deactivation/pom.xml | 35 +++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 maven-project/src/test/resources-project-builder/profile-default-deactivation/pom.xml diff --git a/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java b/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java index ce55cc0935..631e3dfe2d 100644 --- a/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java +++ b/maven-project/src/main/java/org/apache/maven/profiles/DefaultProfileManager.java @@ -50,7 +50,7 @@ public class DefaultProfileManager private static final ProfileMatcher defaultMatcher = new DefaultMatcher(); private static final List matchers = - (List) Collections.unmodifiableList( Arrays.asList( new DefaultMatcher(), new PropertyMatcher(), new FileMatcher() ) ); + (List) Collections.unmodifiableList( Arrays.asList( new PropertyMatcher(), new FileMatcher() ) ); /** * the properties passed to the profile manager are the props that @@ -207,7 +207,7 @@ public class DefaultProfileManager { projectProfiles.addAll( externalProfileManager.getActiveProfiles() ); } - + ProfileManager profileManager = new DefaultProfileManager( container, profileActivationContext ); profileManager.addProfiles( model.getProfiles() ); projectProfiles.addAll( profileManager.getActiveProfiles() ); diff --git a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java index 6df9705da1..49541ae23e 100644 --- a/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/PomConstructionTest.java @@ -1284,6 +1284,16 @@ public class PomConstructionTest assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); } + /* MNG-3545 */ + public void testProfileDefaultActivation() + throws Exception + { + PomTestWrapper pom = buildPom( "profile-default-deactivation" , "profile4"); + assertEquals(1, pom.getMavenProject().getActiveProfiles().size() ); + assertEquals(1, ( (List) pom.getValue( "build/plugins" )).size() ); + assertEquals("2.1", pom.getValue( "build/plugins[1]/version" )); + } + /* FIXME: MNG-1995 public void testBooleanInterpolation() throws Exception @@ -1297,7 +1307,6 @@ public class PomConstructionTest throws Exception { PomTestWrapper pom = buildPom( "build-extension-inheritance/sub" ); - System.out.println(pom.getDomainModel().asString()); assertEquals(3, ( (List) pom.getValue( "build/extensions" )).size() ); assertEquals("b", pom.getValue( "build/extensions[1]/artifactId" ) ); assertEquals("a", pom.getValue( "build/extensions[2]/artifactId" ) ); diff --git a/maven-project/src/test/resources-project-builder/profile-default-deactivation/pom.xml b/maven-project/src/test/resources-project-builder/profile-default-deactivation/pom.xml new file mode 100644 index 0000000000..dfe19253f8 --- /dev/null +++ b/maven-project/src/test/resources-project-builder/profile-default-deactivation/pom.xml @@ -0,0 +1,35 @@ + + 4.0.0 + org.apache.maven.its.mng3545 + test-artifact + 1.0-SNAPSHOT + + + profile1 + + true + + + + + org.apache.maven.its.plugins + maven-it-plugin-touch + 2.2 + + + + + + profile4 + + + + org.apache.maven.its.plugins + maven-it-plugin-touch + 2.1 + + + + + +