You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2021/10/05 15:37:45 UTC

[maven] branch MNG-7276 updated (b1e6b28 -> cdf5971)

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a change to branch MNG-7276
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard b1e6b28  Continued.
 discard 9da2d37  [MNG-7276] - Refactoring - Umbrella
     add d141957  [MNG-7055] Fix G level metadata handling (#555)
     add af9c64f  [MNG-6898] Drop plexus-component-metadata plugin from maven-core (#554)
     add c3962c1  [MNG-7278] Clean up core logging (#562)
     add 7934f73  Update DOAP with Maven 3.8.3 release
     add 69ee0c8  [MNG-7103] VersionScheme provider (#563)
     add d75bea4  [MNG-7279] Drop deprecated constructor (#564)
     new d18220d  [MNG-7276] - Refactoring - Umbrella
     new cdf5971  Continued.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (b1e6b28)
            \
             N -- N -- N   refs/heads/MNG-7276 (cdf5971)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doap_Maven.rdf                                     |   9 ++
 maven-compat/pom.xml                               |   5 +
 .../artifact/deployer/ArtifactDeployerTest.java    |  34 +++--
 .../artifact/installer/ArtifactInstallerTest.java  |  26 +++-
 .../apache/maven/project/TestProjectBuilder.java   |   5 +-
 maven-core/pom.xml                                 |   8 --
 .../main/java/org/apache/maven/DefaultMaven.java   |   8 +-
 .../maven/classrealm/DefaultClassRealmManager.java |  11 +-
 .../eventspy/internal/EventSpyDispatcher.java      |   9 +-
 .../DefaultPluginsMetadataInfoProvider.java        | 137 +++++++++++++++++++++
 .../DefaultRepositorySystemSessionFactory.java     |   7 +-
 .../internal/aether/LoggingRepositoryListener.java |   2 +-
 .../apache/maven/lifecycle/DefaultLifecycles.java  |  13 +-
 .../internal/DefaultLifecyclePluginAnalyzer.java   |  55 +++++++--
 .../lifecycle/internal/LifecycleDebugLogger.java   |  12 +-
 .../internal/LifecycleDependencyResolver.java      |   8 +-
 .../maven/lifecycle/internal/LifecycleStarter.java |   9 +-
 .../lifecycle/internal/MojoDescriptorCreator.java  |   8 +-
 .../lifecycle/internal/builder/BuilderCommon.java  |  21 +++-
 .../multithreaded/MultiThreadedBuilder.java        |   8 +-
 .../MavenPluginLifecycleMappingProvider.java       |   6 +-
 .../maven/plugin/DebugConfigurationListener.java   |   4 +-
 .../plugin/PluginParameterExpressionEvaluator.java |  10 --
 .../plugin/internal/DefaultMavenPluginManager.java |  17 +--
 .../DefaultPluginDependenciesResolver.java         |  10 +-
 .../maven/plugin/internal/MojoLogWrapper.java      |  32 +++--
 .../internal/DefaultPluginPrefixResolver.java      |   8 +-
 .../internal/DefaultPluginVersionResolver.java     |  17 ++-
 .../maven/project/DefaultProjectBuilder.java       |   8 +-
 .../project/DefaultProjectBuildingHelper.java      |  10 +-
 .../DefaultProjectDependenciesResolver.java        |   8 +-
 .../project/artifact/DefaultMetadataSource.java    |   5 +-
 .../project/artifact/MavenMetadataSource.java      |  18 ++-
 .../rtinfo/internal/DefaultRuntimeInformation.java |  80 ++++++------
 .../apache/maven/toolchain/DefaultToolchain.java   |   6 +-
 .../maven/toolchain/DefaultToolchainManager.java   |  21 +++-
 .../toolchain/DefaultToolchainManagerPrivate.java  |  17 ++-
 .../maven/toolchain/DefaultToolchainsBuilder.java  |  13 +-
 .../building/DefaultToolchainsBuilder.java         |   4 +-
 .../maven/toolchain/java/DefaultJavaToolChain.java |   2 +-
 .../maven/toolchain/java/JavaToolchainFactory.java |  13 +-
 .../maven/toolchain/java/JavaToolchainImpl.java    |   2 +-
 .../maven/lifecycle/DefaultLifecyclesTest.java     |   3 +-
 .../LifecycleExecutionPlanCalculatorTest.java      |   2 +-
 .../internal/{ => builder}/BuilderCommonTest.java  |  19 +--
 .../internal/stub/DefaultLifecyclesStub.java       |   2 +-
 .../maven/lifecycle/internal/stub/LoggerStub.java  | 110 -----------------
 .../apache/maven/project/TestMetadataSource.java   |   5 +-
 .../DefaultToolchainManagerPrivateTest.java        |   4 +-
 .../toolchain/DefaultToolchainManagerTest.java     |   4 +-
 .../maven/toolchain/DefaultToolchainTest.java      |   7 +-
 .../test/resources/META-INF/plexus/components.xml  | 107 ----------------
 .../internal/BootstrapCoreExtensionManager.java    |   8 +-
 .../internal/DefaultVersionRangeResolver.java      |  11 +-
 .../internal/DefaultVersionSchemeProvider.java     |  37 +++---
 .../repository/internal/MavenResolverModule.java   |   2 +
 .../maven/repository/internal/PluginsMetadata.java | 117 ++++++++++++++++++
 ...enerator.java => PluginsMetadataGenerator.java} |  63 ++++++----
 ...y.java => PluginsMetadataGeneratorFactory.java} |  24 +++-
 ...eader.java => PluginsMetadataInfoProvider.java} |  23 ++--
 60 files changed, 692 insertions(+), 562 deletions(-)
 create mode 100644 maven-core/src/main/java/org/apache/maven/execution/infoproviders/DefaultPluginsMetadataInfoProvider.java
 rename maven-plugin-api/src/main/java/org/apache/maven/monitor/logging/DefaultLog.java => maven-core/src/main/java/org/apache/maven/plugin/internal/MojoLogWrapper.java (86%)
 rename maven-core/src/test/java/org/apache/maven/lifecycle/internal/{ => builder}/BuilderCommonTest.java (82%)
 delete mode 100644 maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LoggerStub.java
 delete mode 100644 maven-core/src/test/resources/META-INF/plexus/components.xml
 copy maven-core/src/main/java/org/apache/maven/extension/internal/CoreExportsProvider.java => maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultVersionSchemeProvider.java (61%)
 create mode 100644 maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadata.java
 copy maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/{VersionsMetadataGenerator.java => PluginsMetadataGenerator.java} (52%)
 copy maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/{VersionsMetadataGeneratorFactory.java => PluginsMetadataGeneratorFactory.java} (68%)
 copy maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/{MavenWorkspaceReader.java => PluginsMetadataInfoProvider.java} (68%)

[maven] 01/02: [MNG-7276] - Refactoring - Umbrella

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-7276
in repository https://gitbox.apache.org/repos/asf/maven.git

commit d18220d54bebf8650bf1b5c75fd4e7787be9b6e0
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Thu Sep 30 19:10:44 2021 +0200

    [MNG-7276] - Refactoring - Umbrella
---
 .../main/java/org/apache/maven/ReactorReader.java  | 73 ++++++++--------------
 .../java/org/apache/maven/RepositoryUtils.java     | 62 +++++++-----------
 .../resolver/filter/ExclusionArtifactFilter.java   | 49 +++++++--------
 .../org/apache/maven/execution/MavenSession.java   | 12 +---
 4 files changed, 76 insertions(+), 120 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 247632a..07f61e0 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -24,20 +24,19 @@ import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import javax.inject.Inject;
-import javax.inject.Named;
-
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Model;
@@ -49,6 +48,9 @@ import org.eclipse.aether.util.artifact.ArtifactIdUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.inject.Inject;
+import javax.inject.Named;
+
 /**
  * An implementation of a workspace reader that knows how to search the Maven reactor for artifacts, either as packaged
  * jar if it has been built, or only compile output directory if packaging hasn't happened yet.
@@ -72,26 +74,22 @@ class ReactorReader
     private final Map<String, List<MavenProject>> projectsByGA;
     private final WorkspaceRepository repository;
 
+    private Function<MavenProject, String> projectIntoKey =
+            s -> ArtifactUtils.key( s.getGroupId(), s.getArtifactId(), s.getVersion() );
+
+    private Function<MavenProject, String> projectIntoVersionlessKey =
+            s -> ArtifactUtils.versionlessKey( s.getGroupId(), s.getArtifactId() );
+
     @Inject
     ReactorReader( MavenSession session )
     {
         this.session = session;
-        this.projectsByGAV = new HashMap<>( session.getAllProjects().size() * 2 );
-        session.getAllProjects().forEach( project ->
-        {
-            String projectId = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() );
-            this.projectsByGAV.put( projectId, project );
-        } );
-
-        projectsByGA = new HashMap<>( projectsByGAV.size() * 2 );
-        for ( MavenProject project : projectsByGAV.values() )
-        {
-            String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
+        this.projectsByGAV =
+                session.getAllProjects().stream()
+                        .collect( Collectors.toMap( projectIntoKey, Function.identity() ) );
 
-            List<MavenProject> projects = projectsByGA.computeIfAbsent( key, k -> new ArrayList<>( 1 ) );
-
-            projects.add( project );
-        }
+        this.projectsByGA = projectsByGAV.values().stream()
+                .collect( Collectors.groupingBy( projectIntoVersionlessKey ) );
 
         repository = new WorkspaceRepository( "reactor", new HashSet<>( projectsByGAV.keySet() ) );
     }
@@ -128,23 +126,11 @@ class ReactorReader
     {
         String key = ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
 
-        List<MavenProject> projects = projectsByGA.get( key );
-        if ( projects == null || projects.isEmpty() )
-        {
-            return Collections.emptyList();
-        }
-
-        List<String> versions = new ArrayList<>();
-
-        for ( MavenProject project : projects )
-        {
-            if ( find( project, artifact ) != null )
-            {
-                versions.add( project.getVersion() );
-            }
-        }
-
-        return Collections.unmodifiableList( versions );
+        return Optional.ofNullable( projectsByGA.get( key ) )
+                .orElse( Collections.emptyList() ).stream()
+                .filter( s -> Objects.nonNull( find( s, artifact ) ) )
+                .map( MavenProject::getVersion )
+                .collect( Collectors.collectingAndThen( Collectors.toList(), Collections::unmodifiableList ) );
     }
 
     @Override
@@ -334,15 +320,10 @@ class ReactorReader
             return mainArtifact;
         }
 
-        for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) )
-        {
-            if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) )
-            {
-                return attachedArtifact;
-            }
-        }
-
-        return null;
+        return RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ).stream()
+                .filter( artifact -> attachedArtifactComparison( requestedArtifact, artifact ) )
+                .findFirst()
+                .orElse( null );
     }
 
     private boolean attachedArtifactComparison( Artifact requested, Artifact attached )
diff --git a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
index a49b670..b8c8837 100644
--- a/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
+++ b/maven-core/src/main/java/org/apache/maven/RepositoryUtils.java
@@ -26,6 +26,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
 
 import org.apache.maven.artifact.handler.ArtifactHandler;
 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
@@ -121,7 +123,7 @@ public class RepositoryUtils
             nodeTrail.addAll( trail );
             nodeTrail.add( artifact.getId() );
 
-            if ( filter == null || filter.accept( node, Collections.<DependencyNode>emptyList() ) )
+            if ( filter == null || filter.accept( node, Collections.emptyList() ) )
             {
                 artifact.setDependencyTrail( nodeTrail );
                 artifacts.add( artifact );
@@ -170,32 +172,21 @@ public class RepositoryUtils
 
         Artifact result = toArtifact( artifact );
 
-        List<Exclusion> excl = null;
-        if ( exclusions != null )
-        {
-            excl = new ArrayList<>( exclusions.size() );
-            for ( org.apache.maven.model.Exclusion exclusion : exclusions )
-            {
-                excl.add( toExclusion( exclusion ) );
-            }
-        }
-
+        List<Exclusion> excl = Optional.ofNullable( exclusions )
+                .orElse( Collections.emptyList() )
+                .stream()
+                .map( RepositoryUtils::toExclusion )
+                .collect( Collectors.toList() );
         return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl );
     }
 
     public static List<RemoteRepository> toRepos( List<ArtifactRepository> repos )
     {
-        if ( repos == null )
-        {
-            return null;
-        }
-
-        List<RemoteRepository> results = new ArrayList<>( repos.size() );
-        for ( ArtifactRepository repo : repos )
-        {
-            results.add( toRepo( repo ) );
-        }
-        return results;
+        return Optional.ofNullable( repos )
+                .orElse( Collections.emptyList() )
+                .stream()
+                .map( RepositoryUtils::toRepo )
+                .collect( Collectors.toList() );
     }
 
     public static RemoteRepository toRepo( ArtifactRepository repo )
@@ -318,20 +309,16 @@ public class RepositoryUtils
             new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null,
                                  dependency.getVersion(), props, stereotype );
 
-        List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() );
-        for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() )
-        {
-            exclusions.add( toExclusion( exclusion ) );
-        }
+        List<Exclusion> exclusions =
+                dependency.getExclusions().stream().map( RepositoryUtils::toExclusion ).collect( Collectors.toList() );
 
-        Dependency result = new Dependency( artifact,
-                                            dependency.getScope(),
-                                            dependency.getOptional() != null
-                                                ? dependency.isOptional()
-                                                : null,
-                                            exclusions );
+        return new Dependency( artifact,
+                dependency.getScope(),
+                dependency.getOptional() != null
+                        ? dependency.isOptional()
+                        : null,
+                exclusions );
 
-        return result;
     }
 
     private static Exclusion toExclusion( org.apache.maven.model.Exclusion exclusion )
@@ -365,12 +352,7 @@ public class RepositoryUtils
 
     public static Collection<Artifact> toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifactsToConvert )
     {
-        List<Artifact> artifacts = new ArrayList<>();
-        for ( org.apache.maven.artifact.Artifact a : artifactsToConvert )
-        {
-            artifacts.add( toArtifact( a ) );
-        }
-        return artifacts;
+        return artifactsToConvert.stream().map( RepositoryUtils::toArtifact ).collect( Collectors.toList() );
     }
 
     public static WorkspaceRepository getWorkspace( RepositorySystemSession session )
diff --git a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
index dd50c31..d58c4a7 100644
--- a/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
+++ b/maven-core/src/main/java/org/apache/maven/artifact/resolver/filter/ExclusionArtifactFilter.java
@@ -19,11 +19,12 @@ package org.apache.maven.artifact.resolver.filter;
  * under the License.
  */
 
+import java.util.List;
+import java.util.function.Predicate;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Exclusion;
 
-import java.util.List;
-
 /**
  * Filter to exclude from a list of artifact patterns.
  */
@@ -38,31 +39,29 @@ public class ExclusionArtifactFilter implements ArtifactFilter
         this.exclusions = exclusions;
     }
 
+    private Predicate<Exclusion> sameArtifactId( Artifact artifact )
+    {
+        return exclusion -> exclusion.getArtifactId().equals( artifact.getArtifactId() );
+    }
+
+    private Predicate<Exclusion> sameGroupId( Artifact artifact )
+    {
+        return exclusion -> exclusion.getGroupId().equals( artifact.getGroupId() );
+    }
+
+    private Predicate<Exclusion> groupIdIsWildcard = exclusion -> WILDCARD.equals( exclusion.getGroupId() );
+    private Predicate<Exclusion> artifactIdIsWildcard = exclusion -> WILDCARD.equals( exclusion.getArtifactId() );
+
+    Predicate<Exclusion> groupIdAndArtifactIdIsWildcard = groupIdIsWildcard.and( artifactIdIsWildcard );
+
     @Override
     public boolean include( Artifact artifact )
     {
-        for ( Exclusion exclusion : exclusions )
-        {
-            if ( WILDCARD.equals( exclusion.getGroupId() ) && WILDCARD.equals( exclusion.getArtifactId() ) )
-            {
-                return false;
-            }
-            if ( WILDCARD.equals( exclusion.getGroupId() )
-                && exclusion.getArtifactId().equals( artifact.getArtifactId() ) )
-            {
-                return false;
-            }
-            if ( WILDCARD.equals( exclusion.getArtifactId() )
-                && exclusion.getGroupId().equals( artifact.getGroupId() ) )
-            {
-                return false;
-            }
-            if ( exclusion.getGroupId().equals( artifact.getGroupId() )
-                && exclusion.getArtifactId().equals( artifact.getArtifactId() ) )
-            {
-                return false;
-            }
-        }
-        return true;
+        return !exclusions.stream().anyMatch(
+                groupIdAndArtifactIdIsWildcard
+                        .or( groupIdIsWildcard.and( sameArtifactId( artifact ) ) )
+                        .or( artifactIdIsWildcard.and( sameGroupId( artifact ) ) )
+                        .or( sameGroupId( artifact ).and( sameArtifactId( artifact ) ) )
+        );
     }
 }
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
index f8dbb03..adde001 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
@@ -84,15 +84,9 @@ public class MavenSession
         if ( !projects.isEmpty() )
         {
             this.currentProject = projects.get( 0 );
-            this.topLevelProject = currentProject;
-            for ( MavenProject project : projects )
-            {
-                if ( project.isExecutionRoot() )
-                {
-                    topLevelProject = project;
-                    break;
-                }
-            }
+            this.topLevelProject =
+                    projects.stream().filter( project -> project.isExecutionRoot() ).findFirst()
+                            .orElse( currentProject );
         }
         else
         {

[maven] 02/02: Continued.

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-7276
in repository https://gitbox.apache.org/repos/asf/maven.git

commit cdf5971a984ffff9bd381cb850e7054eb7d4a7ce
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sun Oct 3 21:42:24 2021 +0200

    Continued.
---
 .../main/java/org/apache/maven/ReactorReader.java  |  8 +++++--
 .../apache/maven/execution/ProfileActivation.java  |  2 +-
 .../maven/extension/internal/CoreExports.java      | 14 +++++------
 .../lifecycle/mapping/DefaultLifecycleMapping.java |  3 ++-
 .../profile/DefaultProfileActivationContext.java   | 27 +++++++---------------
 5 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 07f61e0..1521b1b 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -51,6 +51,10 @@ import org.slf4j.LoggerFactory;
 import javax.inject.Inject;
 import javax.inject.Named;
 
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.groupingBy;
+import static java.util.stream.Collectors.toMap;
+
 /**
  * An implementation of a workspace reader that knows how to search the Maven reactor for artifacts, either as packaged
  * jar if it has been built, or only compile output directory if packaging hasn't happened yet.
@@ -86,10 +90,10 @@ class ReactorReader
         this.session = session;
         this.projectsByGAV =
                 session.getAllProjects().stream()
-                        .collect( Collectors.toMap( projectIntoKey, Function.identity() ) );
+                        .collect( toMap( projectIntoKey, identity() ) );
 
         this.projectsByGA = projectsByGAV.values().stream()
-                .collect( Collectors.groupingBy( projectIntoVersionlessKey ) );
+                .collect( groupingBy( projectIntoVersionlessKey ) );
 
         repository = new WorkspaceRepository( "reactor", new HashSet<>( projectsByGAV.keySet() ) );
     }
diff --git a/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java b/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
index 52f5e06..ad00a74 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/ProfileActivation.java
@@ -133,7 +133,7 @@ public class ProfileActivation
     {
         return this.activations.entrySet().stream()
                 .filter( e -> predicate.test( e.getValue() ) )
-                .map( e -> e.getKey() )
+                .map( Map.Entry::getKey )
                 .collect( toSet() );
     }
 
diff --git a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
index d72b3f9..2d976ae 100644
--- a/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
+++ b/maven-core/src/main/java/org/apache/maven/extension/internal/CoreExports.java
@@ -20,14 +20,16 @@ package org.apache.maven.extension.internal;
  */
 
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
 
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
 
+import static java.util.function.Function.identity;
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toMap;
+
 /**
  * Provides information about artifacts (identified by groupId:artifactId string key) and classpath elements exported by
  * Maven core itself and loaded Maven core extensions.
@@ -47,13 +49,9 @@ public class CoreExports
 
     public CoreExports( ClassRealm realm, Set<String> exportedArtifacts, Set<String> exportedPackages )
     {
-        Map<String, ClassLoader> packages = new LinkedHashMap<>();
-        for ( String pkg : exportedPackages )
-        {
-            packages.put( pkg, realm );
-        }
         this.artifacts = Collections.unmodifiableSet( new HashSet<>( exportedArtifacts ) );
-        this.packages = Collections.unmodifiableMap( new HashMap<>( packages ) );
+        this.packages = exportedPackages.stream().collect(
+                collectingAndThen( toMap( identity(), v -> realm ), Collections::unmodifiableMap ) );
     }
 
     /**
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java
index e1ff314..4001a97 100644
--- a/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/mapping/DefaultLifecycleMapping.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static java.util.function.Function.identity;
 import static java.util.stream.Collectors.toMap;
 
 /**
@@ -57,7 +58,7 @@ public class DefaultLifecycleMapping
     public DefaultLifecycleMapping( final List<Lifecycle> lifecycles )
     {
         this.lifecycleMap = Collections.unmodifiableMap(
-                lifecycles.stream().collect( toMap( Lifecycle::getId, l -> l ) )
+                lifecycles.stream().collect( toMap( Lifecycle::getId, identity() ) )
         );
     }
 
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
index 77d92a3..4fb1b26 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
@@ -21,12 +21,13 @@ package org.apache.maven.model.profile;
 
 import java.io.File;
 import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toMap;
+
 /**
  * Describes the environmental context used to determine the activation status of profiles.
  *
@@ -230,8 +231,11 @@ public class DefaultProfileActivationContext
     {
         if ( projectProperties != null )
         {
-
-            this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) );
+            this.projectProperties = projectProperties.entrySet().stream()
+                    .collect(
+                            collectingAndThen(
+                                    toMap( k -> String.valueOf( k.getKey() ), v -> String.valueOf( v ) ),
+                                    Collections::unmodifiableMap ) );
         }
         else
         {
@@ -241,19 +245,4 @@ public class DefaultProfileActivationContext
         return this;
     }
 
-    private Map<String, String> toMap( Properties properties )
-    {
-        if ( properties == null )
-        {
-            return Collections.emptyMap();
-        }
-        Map<String, String> map = new HashMap<>();
-        Enumeration keys = properties.keys();
-        while ( keys.hasMoreElements() )
-        {
-            String key = (String) keys.nextElement();
-            map.put( key, properties.getProperty( key ) );
-        }
-        return map;
-    }
 }