mirror of https://github.com/apache/maven.git
merge from branch rev.379473
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@379481 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17302c0e24
commit
8a630687b7
|
@ -22,6 +22,11 @@
|
|||
<artifactId>maven-profile</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-settings</artifactId>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
|
|
|
@ -4,6 +4,8 @@ import org.apache.maven.model.Activation;
|
|||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.profiles.activation.ProfileActivator;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.SettingsUtils;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
@ -31,19 +33,29 @@ import java.util.Map.Entry;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public class DefaultProfileManager implements ProfileManager
|
||||
public class DefaultProfileManager
|
||||
implements ProfileManager
|
||||
{
|
||||
private PlexusContainer container;
|
||||
|
||||
private List activatedIds = new ArrayList();
|
||||
|
||||
private List deactivatedIds = new ArrayList();
|
||||
|
||||
private List defaultIds = new ArrayList();
|
||||
|
||||
private Map profilesById = new HashMap();
|
||||
|
||||
public DefaultProfileManager( PlexusContainer container )
|
||||
{
|
||||
this( container, null );
|
||||
}
|
||||
|
||||
public DefaultProfileManager( PlexusContainer container, Settings settings )
|
||||
{
|
||||
this.container = container;
|
||||
|
||||
loadSettingsProfiles( settings );
|
||||
}
|
||||
|
||||
public Map getProfilesById()
|
||||
|
@ -61,9 +73,8 @@ public class DefaultProfileManager implements ProfileManager
|
|||
Profile existing = (Profile) profilesById.get( profileId );
|
||||
if ( existing != null )
|
||||
{
|
||||
container.getLogger().warn(
|
||||
"Overriding profile: \'" + profileId + "\' (source: " + existing.getSource()
|
||||
+ ") with new instance from source: " + profile.getSource() );
|
||||
container.getLogger().warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() +
|
||||
") with new instance from source: " + profile.getSource() );
|
||||
}
|
||||
|
||||
profilesById.put( profile.getId(), profile );
|
||||
|
@ -131,7 +142,8 @@ public class DefaultProfileManager implements ProfileManager
|
|||
/* (non-Javadoc)
|
||||
* @see org.apache.maven.profiles.ProfileManager#getActiveProfiles()
|
||||
*/
|
||||
public List getActiveProfiles() throws ProfileActivationException
|
||||
public List getActiveProfiles()
|
||||
throws ProfileActivationException
|
||||
{
|
||||
List active = new ArrayList( profilesById.size() );
|
||||
|
||||
|
@ -240,4 +252,29 @@ public class DefaultProfileManager implements ProfileManager
|
|||
return defaultIds;
|
||||
}
|
||||
|
||||
private void loadSettingsProfiles( Settings settings )
|
||||
{
|
||||
if ( settings == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List settingsProfiles = settings.getProfiles();
|
||||
|
||||
if ( settingsProfiles != null && !settingsProfiles.isEmpty() )
|
||||
{
|
||||
List settingsActiveProfileIds = settings.getActiveProfiles();
|
||||
|
||||
explicitlyActivate( settingsActiveProfileIds );
|
||||
|
||||
for ( Iterator it = settings.getProfiles().iterator(); it.hasNext(); )
|
||||
{
|
||||
org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next();
|
||||
|
||||
Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
|
||||
|
||||
addProfile( profile );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue