diff --git a/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java b/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java index a14e2f4dd..641573568 100644 --- a/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java +++ b/maven-resolver-supplier/src/main/java/org/eclipse/aether/supplier/SessionBuilderSupplier.java @@ -56,7 +56,13 @@ * Extend this class and override methods to customize, if needed. * * @since 2.0.0 + * + * @deprecated (To be removed as it was introduced in 2.0.0-alpha-2!) This class is wrong, as it uses Resolver 1.x + * bits that do interpret dependency scopes. The proper session supplier should be provided by consumer project + * (Maven) that also defines the dependency scopes and their meaning and semantics, as session need to be equipped + * with these bits. Session is very much dependent on the consumer project. */ +@Deprecated public class SessionBuilderSupplier implements Supplier { protected final RepositorySystem repositorySystem; diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java index 6238d924f..0193dcddb 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/JavaScopes.java @@ -22,14 +22,19 @@ * The dependency scopes used for Java dependencies. * * @see org.eclipse.aether.graph.Dependency#getScope() + * + * @deprecated Definition and semantics of the scopes should be defined by consumer project. Resolver out-of-the-box + * supported scopes are defined in {@link Scopes} class. Resolver is oblivious about any other scopes and their + * semantics. */ +@Deprecated public final class JavaScopes { public static final String COMPILE = "compile"; public static final String PROVIDED = "provided"; - public static final String SYSTEM = "system"; + public static final String SYSTEM = Scopes.SYSTEM; public static final String RUNTIME = "runtime"; diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/Scopes.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/Scopes.java new file mode 100644 index 000000000..a78ba47a6 --- /dev/null +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/Scopes.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.eclipse.aether.util.artifact; + +/** + * The dependency scopes that Resolver supports out of the box. The full set of scopes should be defined by + * consumer project. + *

+ * By definition, scopes for Resolver are just labels, checked for equality. Resolver will not interpret, alter or + * modify any scope "label" that is not present in this class. It is left to consumer projects to define and + * interpret those. + * + * @see org.eclipse.aether.graph.Dependency#getScope() + * @since 2.0.0 + */ +public final class Scopes { + + /** + * Special scope that tells resolver that dependency is not to be found in any regular repository, so it should not + * even try to resolve the artifact from them. Dependency in this scope does not have artifact descriptor either. + * Artifacts in this scope should have the "local path" property set, pointing to a file on local system, where the + * backing file should reside. Resolution of artifacts in this scope fails, if backing file does not exist + * (no property set, or property contains invalid path, or the path points to a non-existent file). + * + * @see org.eclipse.aether.artifact.ArtifactProperties#LOCAL_PATH + */ + public static final String SYSTEM = "system"; + + private Scopes() { + // hide constructor + } +} diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java index 438187eff..378cc82fa 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/filter/DependencyFilterUtils.java @@ -112,7 +112,12 @@ public static DependencyFilter orFilter(Collection filters) { * @param classpathTypes The classpath types, may be {@code null} or empty to match no dependency. * @return The new filter, never {@code null}. * @see JavaScopes + * + * @deprecated Resolver is oblivious about "scopes", it is consumer project which needs to lay these down and + * also assign proper semantics. Moreover, Resolver is oblivious about notions of "classpath", "modulepath", and + * any other similar uses. These should be handled by consumer project. */ + @Deprecated public static DependencyFilter classpathFilter(String... classpathTypes) { return classpathFilter((classpathTypes != null) ? Arrays.asList(classpathTypes) : null); } @@ -124,7 +129,12 @@ public static DependencyFilter classpathFilter(String... classpathTypes) { * @param classpathTypes The classpath types, may be {@code null} or empty to match no dependency. * @return The new filter, never {@code null}. * @see JavaScopes + * + * @deprecated Resolver is oblivious about "scopes", it is consumer project which needs to lay these down and + * also assign proper semantics. Moreover, Resolver is oblivious about notions of "classpath", "modulepath", and + * any other similar uses. These should be handled by consumer project. */ + @Deprecated public static DependencyFilter classpathFilter(Collection classpathTypes) { Collection types = new HashSet<>(); diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java index 5cf7ebb3c..76f1afb4b 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/manager/AbstractDependencyManager.java @@ -32,7 +32,7 @@ import org.eclipse.aether.collection.DependencyManager; import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.Exclusion; -import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.artifact.Scopes; import static java.util.Objects.requireNonNull; @@ -195,7 +195,7 @@ public DependencyManagement manageDependency(Dependency dependency) { } management.setScope(scope); - if (!JavaScopes.SYSTEM.equals(scope) + if (!Scopes.SYSTEM.equals(scope) && dependency.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != null) { Map properties = new HashMap<>(dependency.getArtifact().getProperties()); @@ -204,8 +204,7 @@ public DependencyManagement manageDependency(Dependency dependency) { } } - if ((JavaScopes.SYSTEM.equals(scope)) - || (scope == null && JavaScopes.SYSTEM.equals(dependency.getScope()))) { + if ((Scopes.SYSTEM.equals(scope)) || (scope == null && Scopes.SYSTEM.equals(dependency.getScope()))) { String localPath = managedLocalPaths.get(key); if (localPath != null) { if (management == null) { diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefiner.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefiner.java index 0b8c93dcb..6d4c54fd9 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefiner.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaDependencyContextRefiner.java @@ -29,11 +29,16 @@ /** * A dependency graph transformer that refines the request context for nodes that belong to the "project" context by - * appending the classpath type to which the node belongs. For instance, a compile-time project dependency will be + * appending the buildpath type to which the node belongs. For instance, a compile-time project dependency will be * assigned the request context "project/compile". * * @see DependencyNode#getRequestContext() + * + * @deprecated This class belongs to consumer project. Resolver have no notion of scopes other than those defined + * in {@link org.eclipse.aether.util.artifact.Scopes} class, moreover it has no knowledge about scope transformation + * of dependencies to build path scopes. */ +@Deprecated public final class JavaDependencyContextRefiner implements DependencyGraphTransformer { public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransformationContext context) @@ -43,7 +48,7 @@ public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransfo String ctx = node.getRequestContext(); if ("project".equals(ctx)) { - String scope = getClasspathScope(node); + String scope = getBuildpathScope(node); if (scope != null) { ctx += '/' + scope; node.setRequestContext(ctx); @@ -57,7 +62,7 @@ public DependencyNode transformGraph(DependencyNode node, DependencyGraphTransfo return node; } - private String getClasspathScope(DependencyNode node) { + private String getBuildpathScope(DependencyNode node) { Dependency dependency = node.getDependency(); if (dependency == null) { return null; diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeDeriver.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeDeriver.java index 050af9f0a..d0aa1b41c 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeDeriver.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeDeriver.java @@ -25,7 +25,12 @@ /** * A scope deriver for use with {@link ConflictResolver} that supports the scopes from {@link JavaScopes}. + * + * @deprecated This class belongs to consumer project. Resolver have no notion of scopes other than those defined + * in {@link org.eclipse.aether.util.artifact.Scopes} class, moreover it has no knowledge about scope transformation + * of dependencies to build path scopes. */ +@Deprecated public final class JavaScopeDeriver extends ScopeDeriver { /** diff --git a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelector.java b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelector.java index 0e80671b6..8661beb6d 100644 --- a/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelector.java +++ b/maven-resolver-util/src/main/java/org/eclipse/aether/util/graph/transformer/JavaScopeSelector.java @@ -32,7 +32,12 @@ * A scope selector for use with {@link ConflictResolver} that supports the scopes from {@link JavaScopes}. In general, * this selector picks the widest scope present among conflicting dependencies where e.g. "compile" is wider than * "runtime" which is wider than "test". If however a direct dependency is involved, its scope is selected. + * + * @deprecated This class belongs to consumer project. Resolver have no notion of scopes other than those defined + * in {@link org.eclipse.aether.util.artifact.Scopes} class, moreover it has no knowledge about scope transformation + * of dependencies to build path scopes. */ +@Deprecated public final class JavaScopeSelector extends ScopeSelector { /**