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/05 16:47:16 UTC

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

slawekjaranowski opened a new pull request, #863:
URL: https://github.com/apache/maven/pull/863

   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [x] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
          for the change (usually before you start working on it).  Trivial changes like typos do not
          require a JIRA issue. Your pull request should address just this issue, without
          pulling in other changes.
    - [x] Each commit in the pull request should have a meaningful subject line and body.
    - [x] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX`
          and `SUMMARY` with the appropriate JIRA issue. Best practice is to use the JIRA issue
          title in the pull request title and in the first line of the commit message.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
          be performed on your pull request automatically.
    - [x] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [x] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1014831807


##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -150,6 +152,8 @@ public DefaultRepositorySystemSession newRepositorySession( MavenExecutionReques
         configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
         configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() );
         configProps.put( "maven.startTime", request.getStartTime() );
+        // First add properties populated from settings.xml
+        configProps.putAll( getConfigFromRequestProfiles( request ) );
         // Resolver's ConfigUtils solely rely on config properties, that is why we need to add both here as well.

Review Comment:
   I think this order also complies with preferred inheritance at point 7: https://cwiki.apache.org/confluence/display/MAVEN/Commandline+inheritance



-- 
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


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

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1017667664


##########
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:
   unsure about filtering as well... IMO is not needed.



-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1017192026


##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -150,6 +152,8 @@ public DefaultRepositorySystemSession newRepositorySession( MavenExecutionReques
         configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
         configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() );
         configProps.put( "maven.startTime", request.getStartTime() );
+        // First add properties populated from settings.xml
+        configProps.putAll( getConfigFromRequestProfiles( request ) );
         // Resolver's ConfigUtils solely rely on config properties, that is why we need to add both here as well.

Review Comment:
   so order is correct



-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1017167037


##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -150,6 +152,8 @@ public DefaultRepositorySystemSession newRepositorySession( MavenExecutionReques
         configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
         configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() );
         configProps.put( "maven.startTime", request.getStartTime() );
+        // First add properties populated from settings.xml
+        configProps.putAll( getConfigFromRequestProfiles( request ) );

Review Comment:
   method renamed



-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1310138531

   > Well, sorry for late as I missed: due https://issues.apache.org/jira/browse/MRESOLVER-284 this is not true for ANY settings.... as we talk here only about session config properties, but if you look at linked issue, some of config properties are expected from PlexusContext/SisuParameters.... this also means that this PR makes it impossible to have these expected as parameters to be set from settings.xml, and this is why I think is better thing to do:
   > 
   >     * on short term, to have all these in `$MAVEN_ARGS` or `.mvn/maven.conf` (or mavenrc)
   > 
   >     * on long term we need something dedicated I guess
   > 
   > 
   > So, again, sorry, but I'd -1 this and rollback the commit as well, but am open to discussion.
   
   I don't understand the contradiction. ARen't the settings props read before the session is created? So for those which it can apply it will apply?


-- 
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


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

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1311520573

   > But I'm not sure if it was the best step - but it is another topic, I can misunderstood something.
   
   Today, sadly after 1.9.0 is out, am also not sure was it the best solution, as it breaks the "session is the config" dogma... and will probably fix it in 1.9.1 or so.... So, basically, this PR may work as is, and I will rework internals of resolver to NOT require this.


-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1014832112


##########
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:
   We don't filter properties from user or system, why here?



##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -150,6 +152,8 @@ public DefaultRepositorySystemSession newRepositorySession( MavenExecutionReques
         configProps.put( ConfigurationProperties.USER_AGENT, getUserAgent() );
         configProps.put( ConfigurationProperties.INTERACTIVE, request.isInteractiveMode() );
         configProps.put( "maven.startTime", request.getStartTime() );
+        // First add properties populated from settings.xml
+        configProps.putAll( getConfigFromRequestProfiles( request ) );

Review Comment:
   getPropertiesFromRequestedProfiles()?



-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1017694640


##########
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:
   filtering removed



-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #863:
URL: https://github.com/apache/maven/pull/863#discussion_r1017653958


##########
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:
   @cstamas WDYT? I think the filter is not required here.



-- 
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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1311521523

   I am pulling back my veto, so leave all as is (port it to master probably as well).


-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1311526340

   This is on master - here is cherry-pick to 3.9 #867 


-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1310349244

   I also think that the most configuration will be worked.
   I see that only `aether.syncContext.named.factory` and `aether.syncContext.named.nameMapper`
   was moved from session scope to container scope.
   
   But I'm not sure if it was the best step - but it is another topic, I can misunderstood something.


-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1304761366

   Intersting case. Will review next week.


-- 
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


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

Posted by GitBox <gi...@apache.org>.
slawekjaranowski merged PR #863:
URL: https://github.com/apache/maven/pull/863


-- 
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


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

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1309483709

   Yet another thing came to my mind: Consider people use custom components in Resolver and they need access to all config props, then filtering would break it. So all is good.


-- 
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


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

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #863:
URL: https://github.com/apache/maven/pull/863#issuecomment-1309864925

   Well, sorry for late as I missed: due https://issues.apache.org/jira/browse/MRESOLVER-284 this is not true for ANY settings.... as we talk here only about session config properties, but if you look at linked issue, some of config properties are expected from PlexusContext/SisuParameters.... this also means that this PR makes it impossible to have these expected as parameters to be set from settings.xml, and this is why I think is better thing to do:
   * on short term, to have all these in `$MAVEN_ARGS` or `.mvn/maven.conf` (or mavenrc)
   * on long term we need something dedicated I guess
   
   So, again, sorry, but I'd -1 this and rollback the commit as well, but am open to discussion.


-- 
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