CLI cannot deactivate a profile that's activated in POM via <activeByDefault> -----------------------------------------------------------------------------
Key: MNG-3640 URL: http://jira.codehaus.org/browse/MNG-3640 Project: Maven 2 Issue Type: Bug Components: Profiles Affects Versions: 2.0.9 Reporter: Kohsuke Kawaguchi Consider the following POM: {noformat} <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>test</groupId> <artifactId>test</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>test</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <profiles> <profile> <id>yuck</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <plugins> <plugin> <groupId>no-such-plugin</groupId> <artifactId>just-to-cause-error</artifactId> </plugin> </plugins> </build> </profile> </profiles> </project> {noformat} I'd like to deactivate the "yuck" profile that kicks in by default. I cannot do this even if I run "mvn -P -yuck". This is because the DefaultProfileManager.getActiveProfiles() is implemented as follows: {noformat} public List getActiveProfiles() throws ProfileActivationException { List activeFromPom = new ArrayList(); List activeExternal = new ArrayList(); for ( Iterator it = profilesById.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Entry) it.next(); String profileId = (String) entry.getKey(); Profile profile = (Profile) entry.getValue(); boolean shouldAdd = false; if ( activatedIds.contains( profileId ) ) { shouldAdd = true; } else if ( !deactivatedIds.contains( profileId ) && isActive( profile ) ) { shouldAdd = true; } if ( shouldAdd ) { if ( "pom".equals( profile.getSource() ) ) { activeFromPom.add( profile ); } else { activeExternal.add( profile ); } } } if ( activeFromPom.isEmpty() ) { for ( Iterator it = defaultIds.iterator(); it.hasNext(); ) { String profileId = (String) it.next(); Profile profile = (Profile) profilesById.get( profileId ); activeFromPom.add( profile ); } } List allActive = new ArrayList( activeFromPom.size() + activeExternal.size() ); allActive.addAll( activeExternal ); allActive.addAll( activeFromPom ); return allActive; } {noformat} ... and therefore the {{defaultIds}} set (which contains "yuck") is considered active, even if {{deactivatedIds}} contain them. The fix should be obvious by now. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira