[ 
https://issues.apache.org/jira/browse/MNG-7960?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17799279#comment-17799279
 ] 

ASF GitHub Bot commented on MNG-7960:
-------------------------------------

gnodet commented on code in PR #1353:
URL: https://github.com/apache/maven/pull/1353#discussion_r1433547141


##########
maven-core/src/main/java/org/apache/maven/internal/aether/DefaultRepositorySystemSessionFactory.java:
##########
@@ -406,6 +443,75 @@ public SessionBuilder 
newRepositorySessionBuilder(MavenExecutionRequest request)
         return session;
     }
 
+    private VersionFilter buildVersionFilter(Map<Object, Object> configProps) {
+        ArrayList<VersionFilter> filters = new ArrayList<>();
+        String filterExpression = (String) 
configProps.get(MAVEN_VERSION_FILTERS);
+        if (filterExpression != null) {
+            List<String> expressions = 
Arrays.stream(filterExpression.split(","))
+                    .filter(s -> s != null && !s.trim().isEmpty())
+                    .collect(Collectors.toList());
+            for (String expression : expressions) {
+                if ("h".equals(expression)) {
+                    filters.add(new HighestVersionFilter());
+                } else if (expression.startsWith("h(") && 
expression.endsWith(")")) {
+                    int num = Integer.parseInt(expression.substring(2, 
expression.length() - 1));
+                    // MRESOLVER-450
+                    // filters.add(new HighestVersionFilter(num));

Review Comment:
   I think it's https://github.com/apache/maven-resolver/pull/401 / 
MRESOLVER-460.
   This PR should be moved to draft to avoid anyone forgetting it's not 
finished and we need next resolver alpha.





> Artifact collection filtering
> -----------------------------
>
>                 Key: MNG-7960
>                 URL: https://issues.apache.org/jira/browse/MNG-7960
>             Project: Maven
>          Issue Type: New Feature
>          Components: Artifacts and Repositories
>            Reporter: Tamas Cservenak
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 4.0.0, 4.0.0-alpha-12
>
>
> Exposed work from MRESOLVER-451 and MRESOLVER-460: allow for various 
> filterings.
> User should be able to "tune" range processing. Also, as this affects 
> resolution, ideally these "tuned" parameters should be stored along project, 
> especially if project relies on these (ie. in {{.mvn/maven.config}}).
> Explanation: Maven is notoriously "bad" when ranges are being used. Hence, 
> this issue introduces (range) version filtering support. The configuration 
> accepts an "expression" (CSV) of filters. Supported filters are:
> * "h" (equivalent of "h(1)") or "h(N)" - that selects "top N" versions from 
> range
> *  "l" (equivalent of "l(1)") or "l(N)" - that selects "bottom N" versions 
> from range
> * "s" snapshot filter: if root/project is snapshot, will allow snapshots in 
> ranges, otherwise snapshot versions are filtered out (also see Resolver 
> config {{aether.snapshotFilter}} present in Resolver 1.x but has no effect in 
> Maven3 as it is not used).
> * "e(G:A:V)" exclusion, if range for G:A is processed, V is _excluded_ from 
> range. V can be version range as well, then whole range is excluded.
> The built expressions are evaluated in-order, and filtering effect is 
> accumulated. Hence, expression like "h(5),l" will return 5th highest version, 
> etc.
> This depends on resolver release.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to