mirror of https://github.com/apache/maven.git
Resolving: MNG-814. Enabled import of explicit activation and deactivation of profileIds from the external profile manager to the project-level profile manager. See it0067.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
159b48c4e7
commit
37d3fd3fdd
|
@ -187,6 +187,8 @@ it0065: Test that the basedir of the parent is set correctly.
|
|||
|
||||
it0066: Test that nonstandard POM files will be installed correctly.
|
||||
|
||||
it0067: Test activation of a profile from the command line.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
it0067
|
||||
it0066
|
||||
it0065
|
||||
it0064
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
-P test-profile
|
|
@ -0,0 +1 @@
|
|||
target/classes/org/apache/maven/it0021/Person.class
|
|
@ -0,0 +1 @@
|
|||
compile
|
|
@ -0,0 +1,21 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.plugins.it</groupId>
|
||||
<artifactId>maven-it0067-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>test-profile</id>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
rm ${artifact:org.apache.maven:maven-core-it-support:1.0:jar}
|
|
@ -0,0 +1,18 @@
|
|||
package org.apache.maven.it0021;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class Person
|
||||
{
|
||||
private String name;
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -10,11 +10,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/*
|
||||
|
@ -37,9 +35,9 @@ public class DefaultProfileManager implements ProfileManager
|
|||
{
|
||||
private PlexusContainer container;
|
||||
|
||||
private Set activatedIds = new HashSet();
|
||||
private Set deactivatedIds = new HashSet();
|
||||
private Set defaultIds = new HashSet();
|
||||
private List activatedIds = new ArrayList();
|
||||
private List deactivatedIds = new ArrayList();
|
||||
private List defaultIds = new ArrayList();
|
||||
|
||||
private Map profilesById = new HashMap();
|
||||
|
||||
|
@ -48,25 +46,6 @@ public class DefaultProfileManager implements ProfileManager
|
|||
this.container = container;
|
||||
}
|
||||
|
||||
public DefaultProfileManager( ProfileManager globals, PlexusContainer container )
|
||||
{
|
||||
this.container = container;
|
||||
|
||||
this.activatedIds.addAll( globals.getActivatedIds() );
|
||||
this.deactivatedIds.addAll( globals.getDeactivatedIds() );
|
||||
this.profilesById.putAll( globals.getProfilesById() );
|
||||
}
|
||||
|
||||
public Set getActivatedIds()
|
||||
{
|
||||
return activatedIds;
|
||||
}
|
||||
|
||||
public Set getDeactivatedIds()
|
||||
{
|
||||
return deactivatedIds;
|
||||
}
|
||||
|
||||
public Map getProfilesById()
|
||||
{
|
||||
return profilesById;
|
||||
|
@ -102,9 +81,12 @@ public class DefaultProfileManager implements ProfileManager
|
|||
*/
|
||||
public void explicitlyActivate( String profileId )
|
||||
{
|
||||
container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly activated." );
|
||||
|
||||
activatedIds.add( profileId );
|
||||
if ( !activatedIds.contains( profileId ) )
|
||||
{
|
||||
container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly activated." );
|
||||
|
||||
activatedIds.add( profileId );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -125,9 +107,12 @@ public class DefaultProfileManager implements ProfileManager
|
|||
*/
|
||||
public void explicitlyDeactivate( String profileId )
|
||||
{
|
||||
container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly deactivated." );
|
||||
|
||||
deactivatedIds.add( profileId );
|
||||
if ( !deactivatedIds.contains( profileId ) )
|
||||
{
|
||||
container.getLogger().debug( "Profile with id: \'" + profileId + "\' has been explicitly deactivated." );
|
||||
|
||||
deactivatedIds.add( profileId );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -234,7 +219,25 @@ public class DefaultProfileManager implements ProfileManager
|
|||
|
||||
public void activateAsDefault( String profileId )
|
||||
{
|
||||
defaultIds.add( profileId );
|
||||
if ( !defaultIds.contains( profileId ) )
|
||||
{
|
||||
defaultIds.add( profileId );
|
||||
}
|
||||
}
|
||||
|
||||
public List getExplicitlyActivatedIds()
|
||||
{
|
||||
return activatedIds;
|
||||
}
|
||||
|
||||
public List getExplicitlyDeactivatedIds()
|
||||
{
|
||||
return deactivatedIds;
|
||||
}
|
||||
|
||||
public List getIdsActivatedByDefault()
|
||||
{
|
||||
return defaultIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.apache.maven.profiles.activation.ProfileActivationException;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ProfileManager
|
||||
{
|
||||
|
@ -27,10 +26,12 @@ public interface ProfileManager
|
|||
|
||||
void addProfiles( List profiles );
|
||||
|
||||
public Set getActivatedIds();
|
||||
Map getProfilesById();
|
||||
|
||||
public Set getDeactivatedIds();
|
||||
List getExplicitlyActivatedIds();
|
||||
|
||||
public Map getProfilesById();
|
||||
List getExplicitlyDeactivatedIds();
|
||||
|
||||
List getIdsActivatedByDefault();
|
||||
|
||||
}
|
|
@ -433,7 +433,7 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
private MavenProject build( String pomLocation, Model model, ArtifactRepository localRepository,
|
||||
List parentSearchRepositories, File projectDir, ProfileManager profileManager )
|
||||
List parentSearchRepositories, File projectDir, ProfileManager externalProfileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
Model superModel = getSuperModel();
|
||||
|
@ -461,9 +461,9 @@ public class DefaultMavenProjectBuilder
|
|||
List activeExternalProfiles;
|
||||
try
|
||||
{
|
||||
if ( profileManager != null )
|
||||
if ( externalProfileManager != null )
|
||||
{
|
||||
activeExternalProfiles = profileManager.getActiveProfiles();
|
||||
activeExternalProfiles = externalProfileManager.getActiveProfiles();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -494,7 +494,7 @@ public class DefaultMavenProjectBuilder
|
|||
Model originalModel = ModelUtils.cloneModel( model );
|
||||
|
||||
MavenProject project = assembleLineage( model, lineage, localRepository, projectDir, parentSearchRepositories,
|
||||
aggregatedRemoteWagonRepositories );
|
||||
aggregatedRemoteWagonRepositories, externalProfileManager );
|
||||
|
||||
project.setOriginalModel( originalModel );
|
||||
|
||||
|
@ -526,7 +526,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
try
|
||||
{
|
||||
project = processProjectLogic( pomLocation, project, repositories, profileManager, projectDir );
|
||||
project = processProjectLogic( pomLocation, project, repositories, externalProfileManager, projectDir );
|
||||
}
|
||||
catch ( ModelInterpolationException e )
|
||||
{
|
||||
|
@ -658,7 +658,7 @@ public class DefaultMavenProjectBuilder
|
|||
*/
|
||||
private MavenProject assembleLineage( Model model, LinkedList lineage, ArtifactRepository localRepository,
|
||||
File projectDir, List parentSearchRepositories,
|
||||
Set aggregatedRemoteWagonRepositories )
|
||||
Set aggregatedRemoteWagonRepositories, ProfileManager externalProfileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( !model.getRepositories().isEmpty() )
|
||||
|
@ -677,6 +677,12 @@ public class DefaultMavenProjectBuilder
|
|||
}
|
||||
|
||||
ProfileManager profileManager = new DefaultProfileManager( container );
|
||||
|
||||
if ( externalProfileManager != null )
|
||||
{
|
||||
profileManager.explicitlyActivate( externalProfileManager.getExplicitlyActivatedIds() );
|
||||
profileManager.explicitlyDeactivate( externalProfileManager.getExplicitlyDeactivatedIds() );
|
||||
}
|
||||
|
||||
List activeProfiles;
|
||||
|
||||
|
@ -813,7 +819,8 @@ public class DefaultMavenProjectBuilder
|
|||
parentProjectDir = parentDescriptor.getParentFile();
|
||||
}
|
||||
MavenProject parent = assembleLineage( model, lineage, localRepository, parentProjectDir,
|
||||
parentSearchRepositories, aggregatedRemoteWagonRepositories );
|
||||
parentSearchRepositories, aggregatedRemoteWagonRepositories,
|
||||
externalProfileManager );
|
||||
parent.setFile( parentDescriptor );
|
||||
|
||||
project.setParent( parent );
|
||||
|
|
Loading…
Reference in New Issue