[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
This commit is contained in:
Britton Isbell 2009-04-07 13:28:02 +00:00
parent 5ae7bdc3fd
commit 57568aa984
3 changed files with 47 additions and 3 deletions

View File

@ -50,7 +50,7 @@ public class DefaultProfileManager
private static final ProfileMatcher defaultMatcher = new DefaultMatcher(); private static final ProfileMatcher defaultMatcher = new DefaultMatcher();
private static final List<ProfileMatcher> matchers = private static final List<ProfileMatcher> matchers =
(List<ProfileMatcher>) Collections.unmodifiableList( Arrays.asList( new DefaultMatcher(), new PropertyMatcher(), new FileMatcher() ) ); (List<ProfileMatcher>) Collections.unmodifiableList( Arrays.asList( new PropertyMatcher(), new FileMatcher() ) );
/** /**
* the properties passed to the profile manager are the props that * the properties passed to the profile manager are the props that
@ -207,7 +207,7 @@ public class DefaultProfileManager
{ {
projectProfiles.addAll( externalProfileManager.getActiveProfiles() ); projectProfiles.addAll( externalProfileManager.getActiveProfiles() );
} }
ProfileManager profileManager = new DefaultProfileManager( container, profileActivationContext ); ProfileManager profileManager = new DefaultProfileManager( container, profileActivationContext );
profileManager.addProfiles( model.getProfiles() ); profileManager.addProfiles( model.getProfiles() );
projectProfiles.addAll( profileManager.getActiveProfiles() ); projectProfiles.addAll( profileManager.getActiveProfiles() );

View File

@ -1284,6 +1284,16 @@ public class PomConstructionTest
assertEquals( "CHILD", pom.getValue( "properties/interpolated" ) ); 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 /* FIXME: MNG-1995
public void testBooleanInterpolation() public void testBooleanInterpolation()
throws Exception throws Exception
@ -1297,7 +1307,6 @@ public class PomConstructionTest
throws Exception throws Exception
{ {
PomTestWrapper pom = buildPom( "build-extension-inheritance/sub" ); PomTestWrapper pom = buildPom( "build-extension-inheritance/sub" );
System.out.println(pom.getDomainModel().asString());
assertEquals(3, ( (List<?>) pom.getValue( "build/extensions" )).size() ); assertEquals(3, ( (List<?>) pom.getValue( "build/extensions" )).size() );
assertEquals("b", pom.getValue( "build/extensions[1]/artifactId" ) ); assertEquals("b", pom.getValue( "build/extensions[1]/artifactId" ) );
assertEquals("a", pom.getValue( "build/extensions[2]/artifactId" ) ); assertEquals("a", pom.getValue( "build/extensions[2]/artifactId" ) );

View File

@ -0,0 +1,35 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3545</groupId>
<artifactId>test-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<profiles>
<profile>
<id>profile1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-touch</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>profile4</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-touch</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>