This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-resolver.git
The following commit(s) were added to refs/heads/master by this push:
new 0f2283a51 Feat: Resolution scope aliases (#1863)
0f2283a51 is described below
commit 0f2283a51001d50c663557e935ea63a163730ff4
Author: Tamas Cservenak <[email protected]>
AuthorDate: Mon May 11 23:08:15 2026 +0200
Feat: Resolution scope aliases (#1863)
A simple feature that simplifies legacy support.
---
.../org/eclipse/aether/scope/ResolutionScope.java | 7 +++++++
.../aether/impl/scope/InternalScopeManager.java | 20 ++++++++++++++++++++
.../aether/internal/impl/scope/ScopeManagerDump.java | 1 +
.../aether/internal/impl/scope/ScopeManagerImpl.java | 11 ++++++++++-
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git
a/maven-resolver-api/src/main/java/org/eclipse/aether/scope/ResolutionScope.java
b/maven-resolver-api/src/main/java/org/eclipse/aether/scope/ResolutionScope.java
index 7fd0b0899..fcde309e2 100644
---
a/maven-resolver-api/src/main/java/org/eclipse/aether/scope/ResolutionScope.java
+++
b/maven-resolver-api/src/main/java/org/eclipse/aether/scope/ResolutionScope.java
@@ -18,6 +18,8 @@
*/
package org.eclipse.aether.scope;
+import java.util.Set;
+
/**
* Generic resolution scope.
*
@@ -31,4 +33,9 @@ public interface ResolutionScope {
* The label.
*/
String getId();
+
+ /**
+ * Aliases, for easier legacy mapping, never {@code null}.
+ */
+ Set<String> getAliases();
}
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/scope/InternalScopeManager.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/scope/InternalScopeManager.java
index 81c002202..d4e2b7228 100644
---
a/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/scope/InternalScopeManager.java
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/impl/scope/InternalScopeManager.java
@@ -19,7 +19,9 @@
package org.eclipse.aether.impl.scope;
import java.util.Collection;
+import java.util.Collections;
import java.util.Optional;
+import java.util.Set;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.collection.CollectResult;
@@ -98,8 +100,26 @@ public interface InternalScopeManager extends ScopeManager {
* <p>
* Should be invoked only via {@link
ScopeManagerConfiguration#buildResolutionScopes(InternalScopeManager)}.
*/
+ default ResolutionScope createResolutionScope(
+ String id,
+ Mode mode,
+ Collection<BuildScopeQuery> wantedPresence,
+ Collection<DependencyScope> explicitlyIncluded,
+ Collection<DependencyScope> transitivelyExcluded) {
+ return createResolutionScope(
+ id, Collections.emptySet(), mode, wantedPresence,
explicitlyIncluded, transitivelyExcluded);
+ }
+
+ /**
+ * Creates resolution scope instance with aliases.
+ * <p>
+ * Should be invoked only via {@link
ScopeManagerConfiguration#buildResolutionScopes(InternalScopeManager)}.
+ *
+ * @since 2.0.18
+ */
ResolutionScope createResolutionScope(
String id,
+ Set<String> aliases,
Mode mode,
Collection<BuildScopeQuery> wantedPresence,
Collection<DependencyScope> explicitlyIncluded,
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerDump.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerDump.java
index 22ef7bcfa..d90c0454f 100644
---
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerDump.java
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerDump.java
@@ -97,6 +97,7 @@ public final class ScopeManagerDump {
.sorted(Comparator.comparing(ResolutionScope::getId))
.forEach(s -> {
System.out.println("* " + s.getId());
+ System.out.println(" Aliases: " +
s.getAliases());
System.out.println(" Directly included: " +
scopeManager.getDirectlyIncludedLabels(s));
System.out.println(" Directly excluded: " +
scopeManager.getDirectlyExcludedLabels(s));
System.out.println(" Transitively excluded: " +
scopeManager.getTransitivelyExcludedLabels(s));
diff --git
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerImpl.java
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerImpl.java
index dd3585577..b35d242f2 100644
---
a/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerImpl.java
+++
b/maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/scope/ScopeManagerImpl.java
@@ -201,11 +201,12 @@ public final class ScopeManagerImpl implements
InternalScopeManager {
@Override
public ResolutionScope createResolutionScope(
String id,
+ Set<String> aliases,
Mode mode,
Collection<BuildScopeQuery> wantedPresence,
Collection<DependencyScope> explicitlyIncluded,
Collection<DependencyScope> transitivelyExcluded) {
- return new ResolutionScopeImpl(id, mode, wantedPresence,
explicitlyIncluded, transitivelyExcluded);
+ return new ResolutionScopeImpl(id, aliases, mode, wantedPresence,
explicitlyIncluded, transitivelyExcluded);
}
private Set<DependencyScope> collectScopes(Collection<BuildScopeQuery>
wantedPresence) {
@@ -411,6 +412,7 @@ public final class ScopeManagerImpl implements
InternalScopeManager {
private class ResolutionScopeImpl implements ResolutionScope {
private final String id;
+ private final Set<String> aliases;
private final Mode mode;
private final Set<BuildScopeQuery> wantedPresence;
private final Set<DependencyScope> directlyIncluded;
@@ -418,11 +420,13 @@ public final class ScopeManagerImpl implements
InternalScopeManager {
private ResolutionScopeImpl(
String id,
+ Set<String> aliases,
Mode mode,
Collection<BuildScopeQuery> wantedPresence,
Collection<DependencyScope> explicitlyIncluded,
Collection<DependencyScope> transitivelyExcluded) {
this.id = requireNonNull(id, "id");
+ this.aliases = Collections.unmodifiableSet(new HashSet<>(aliases));
this.mode = requireNonNull(mode, "mode");
this.wantedPresence = Collections.unmodifiableSet(new
HashSet<>(wantedPresence));
Set<DependencyScope> included = collectScopes(wantedPresence);
@@ -440,6 +444,11 @@ public final class ScopeManagerImpl implements
InternalScopeManager {
return id;
}
+ @Override
+ public Set<String> getAliases() {
+ return aliases;
+ }
+
public Mode getMode() {
return mode;
}