giulong commented on PR #436:
URL: https://github.com/apache/maven-wrapper/pull/436#issuecomment-5084196411

   > getHighestVersion may return SNAPSHOT, hence the loop in my code
   
   `VersionRangeRequest` has a 
[constructor](https://maven.apache.org/resolver/apidocs/org/eclipse/aether/resolution/VersionRangeRequest.html#%3Cinit%3E(org.eclipse.aether.artifact.Artifact,java.util.List,org.eclipse.aether.metadata.Metadata.Nature,java.lang.String))
 accepting the nature (snapshot/release/both). Leveraging that one, the method 
would be:
   
   ```java
   String resolveMavenVersion(String version) {
       try {
           Artifact artifact = new 
DefaultArtifact("org.apache.maven:apache-maven:" + version);
           VersionRangeRequest request = new VersionRangeRequest(
                   artifact, 
session.getCurrentProject().getRemotePluginRepositories(), RELEASE, "wrapper"); 
// <-- here
           
           return repositorySystem
                   .resolveVersionRange(repositorySystemSession, request)
                   .getHighestVersion()
                   .toString();
       } catch (VersionRangeResolutionException e) {
           return version;
       }
   }
   ```
   
   What do you think? Is there anything else to address?


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to