You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/11/06 13:56:14 UTC

[GitHub] [maven] slawekjaranowski commented on a diff in pull request #863: [MNG-7590] Allow to configure resolver by properties in settings.xml

slawekjaranowski commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1014834242


##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -313,6 +317,28 @@ else if ( !MAVEN_RESOLVER_TRANSPORT_AUTO.equals( transport ) )
         return session;
     }
 
+    private Map<?, ?> getConfigFromRequestProfiles( MavenExecutionRequest request )
+    {
+
+        HashSet<String> activeProfileId = new HashSet<>( request.getProfileActivation().getRequiredActiveProfileIds() );
+        activeProfileId.addAll( request.getProfileActivation().getOptionalActiveProfileIds() );
+
+        return request.getProfiles().stream()
+            .filter( profile -> activeProfileId.contains( profile.getId() ) )
+            .map( ModelBase::getProperties )
+            .flatMap( properties -> properties.entrySet().stream() )
+            .filter( entry -> isPropertyForResolver( entry.getKey().toString() ) )
+            .collect(
+                Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, ( k1, k2 ) -> k2  ) );
+    }
+
+    private boolean isPropertyForResolver( String propertyName )
+    {
+        return propertyName != null
+            && ( propertyName.startsWith( "maven.resolver." ) || propertyName.startsWith( "aether." ) );
+    }

Review Comment:
   Good question, @cstamas  what do you think?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org