From e203f0c5d3c1291828b99d012a8735d3159fddaf Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 14 Apr 2009 20:37:34 +0000 Subject: [PATCH] o Fixed detection of default profiles git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@764944 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/profiles/DefaultProfileManager.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) 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 05f1f0d77e..daf55cee4f 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 @@ -36,8 +36,14 @@ import org.apache.maven.project.builder.PomInterpolatorTag; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.MutablePlexusContainer; -import java.util.*; -import java.util.Map.Entry; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; public class DefaultProfileManager implements ProfileManager @@ -51,7 +57,7 @@ public class DefaultProfileManager private static final ProfileMatcher defaultMatcher = new DefaultMatcher(); private static final List matchers = - (List) Collections.unmodifiableList( Arrays.asList( new PropertyMatcher(), new FileMatcher(), new JdkMatcher() ) ); + Collections.unmodifiableList( Arrays.asList( new PropertyMatcher(), new FileMatcher(), new JdkMatcher() ) ); /** * the properties passed to the profile manager are the props that @@ -109,7 +115,7 @@ public class DefaultProfileManager { String profileId = profile.getId(); - Profile existing = (Profile) profilesById.get( profileId ); + Profile existing = profilesById.get( profileId ); if ( existing != null ) { container.getLogger().warn( "Overriding profile: \'" + profileId + "\' (source: " + existing.getSource() + @@ -135,12 +141,10 @@ public class DefaultProfileManager { List activeFromPom = new ArrayList(); List activeExternal = new ArrayList(); - for ( Iterator it = profilesById.entrySet().iterator(); it.hasNext(); ) + for ( Map.Entry entry : profilesById.entrySet() ) { - Map.Entry entry = (Entry) it.next(); - - String profileId = (String) entry.getKey(); - Profile profile = (Profile) entry.getValue(); + String profileId = entry.getKey(); + Profile profile = entry.getValue(); if ( !profileActivationContext.isExplicitlyInactive( profileId ) && (profileActivationContext.isExplicitlyActive( profileId ) || isActive( profile, profileActivationContext ) ) ) @@ -170,7 +174,7 @@ public class DefaultProfileManager { continue; } - Profile profile = (Profile) profilesById.get( profileId ); + Profile profile = profilesById.get( profileId ); if ( profile != null ) { @@ -266,10 +270,8 @@ public class DefaultProfileManager */ public void addProfiles( List profiles ) { - for ( Iterator it = profiles.iterator(); it.hasNext(); ) + for ( Profile profile : profiles ) { - Profile profile = (Profile) it.next(); - addProfile( profile ); } } @@ -279,7 +281,7 @@ public class DefaultProfileManager List defaults = new ArrayList(); for(Profile p : profiles) { - if( (p.getActivation() != null && p.getActivation().isActiveByDefault()) || p.getActivation() == null ) + if ( p.getActivation() != null && p.getActivation().isActiveByDefault() ) { defaults.add( p ); } @@ -310,7 +312,7 @@ public class DefaultProfileManager private void activateAsDefault( String profileId ) { - List defaultIds = profileActivationContext.getActiveByDefaultProfileIds(); + List defaultIds = profileActivationContext.getActiveByDefaultProfileIds(); if ( !defaultIds.contains( profileId ) ) {