artifactDescriptorDecorators) {
+ this.artifactDescriptorDecorators =
+ Objects.requireNonNull(artifactDescriptorDecorators, "artifactDescriptorDecorators cannot be null");
+ return this;
+ }
+
@Override
public ArtifactDescriptorResult readArtifactDescriptor(
RepositorySystemSession session, ArtifactDescriptorRequest request) throws ArtifactDescriptorException {
@@ -232,6 +271,10 @@ public ArtifactDescriptorResult readArtifactDescriptor(
}
delegate.populateResult(session, result, model);
+
+ for (ArtifactDescriptorDecorator decorator : artifactDescriptorDecorators.values()) {
+ decorator.populateArtifactDescriptor(session, result, model);
+ }
}
return result;
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSessionBuilderSupplier.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSessionBuilderSupplier.java
deleted file mode 100644
index 2e0397834c62..000000000000
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/MavenSessionBuilderSupplier.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.apache.maven.repository.internal;
-
-import java.util.Arrays;
-import java.util.Locale;
-import java.util.function.Supplier;
-
-import org.apache.maven.utils.Os;
-import org.eclipse.aether.RepositorySystem;
-import org.eclipse.aether.RepositorySystemSession.CloseableSession;
-import org.eclipse.aether.RepositorySystemSession.SessionBuilder;
-import org.eclipse.aether.artifact.ArtifactTypeRegistry;
-import org.eclipse.aether.artifact.DefaultArtifactType;
-import org.eclipse.aether.collection.DependencyGraphTransformer;
-import org.eclipse.aether.collection.DependencyManager;
-import org.eclipse.aether.collection.DependencySelector;
-import org.eclipse.aether.collection.DependencyTraverser;
-import org.eclipse.aether.internal.impl.scope.OptionalDependencySelector;
-import org.eclipse.aether.internal.impl.scope.ScopeDependencySelector;
-import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
-import org.eclipse.aether.util.artifact.DefaultArtifactTypeRegistry;
-import org.eclipse.aether.util.artifact.JavaScopes;
-import org.eclipse.aether.util.graph.manager.ClassicDependencyManager;
-import org.eclipse.aether.util.graph.selector.AndDependencySelector;
-import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
-import org.eclipse.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
-import org.eclipse.aether.util.graph.transformer.ConfigurableVersionSelector;
-import org.eclipse.aether.util.graph.transformer.ConflictResolver;
-import org.eclipse.aether.util.graph.transformer.JavaDependencyContextRefiner;
-import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
-import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
-import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
-import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser;
-import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * A simple {@link Supplier} of {@link SessionBuilder} instances, that on each call supplies newly
- * constructed instance. To create session out of builder, use {@link SessionBuilder#build()}. For proper closing
- * of sessions, use {@link CloseableSession#close()} method on built instance(s).
- *
- * Extend this class and override methods to customize, if needed.
- *
- * @since 3.10.0
- */
-public class MavenSessionBuilderSupplier implements Supplier {
- protected final RepositorySystem repositorySystem;
-
- public MavenSessionBuilderSupplier(RepositorySystem repositorySystem) {
- this.repositorySystem = requireNonNull(repositorySystem);
- }
-
- protected void configureSessionBuilder(SessionBuilder session) {
- session.setSystemProperties(System.getProperties());
- boolean caseSensitive = !Os.IS_WINDOWS;
- System.getenv().forEach((key, value) -> {
- key = "env." + (caseSensitive ? key : key.toUpperCase(Locale.ENGLISH));
- session.setSystemProperty(key, value);
- });
- session.setDependencyTraverser(getDependencyTraverser());
- session.setDependencyManager(getDependencyManager());
- session.setDependencySelector(getDependencySelector());
- session.setDependencyGraphTransformer(getDependencyGraphTransformer());
- session.setArtifactTypeRegistry(getArtifactTypeRegistry());
- session.setArtifactDescriptorPolicy(getArtifactDescriptorPolicy());
- }
-
- protected DependencyTraverser getDependencyTraverser() {
- return new FatArtifactTraverser();
- }
-
- protected DependencyManager getDependencyManager() {
- return new ClassicDependencyManager();
- }
-
- protected DependencySelector getDependencySelector() {
- return new AndDependencySelector(
- ScopeDependencySelector.legacy(null, Arrays.asList(JavaScopes.TEST, JavaScopes.PROVIDED)),
- OptionalDependencySelector.fromDirect(),
- new ExclusionDependencySelector());
- }
-
- protected DependencyGraphTransformer getDependencyGraphTransformer() {
- return new ChainedDependencyGraphTransformer(
- new ConflictResolver(
- new ConfigurableVersionSelector(),
- new JavaScopeSelector(),
- new SimpleOptionalitySelector(),
- new JavaScopeDeriver()),
- new JavaDependencyContextRefiner());
- }
-
- protected ArtifactTypeRegistry getArtifactTypeRegistry() {
- DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry();
- stereotypes.add(new DefaultArtifactType("pom"));
- stereotypes.add(new DefaultArtifactType("maven-plugin", "jar", "", "java"));
- stereotypes.add(new DefaultArtifactType("jar", "jar", "", "java"));
- stereotypes.add(new DefaultArtifactType("ejb", "jar", "", "java"));
- stereotypes.add(new DefaultArtifactType("ejb-client", "jar", "client", "java"));
- stereotypes.add(new DefaultArtifactType("test-jar", "jar", "tests", "java"));
- stereotypes.add(new DefaultArtifactType("javadoc", "jar", "javadoc", "java"));
- stereotypes.add(new DefaultArtifactType("java-source", "jar", "sources", "java", false, false));
- stereotypes.add(new DefaultArtifactType("war", "war", "", "java", false, true));
- stereotypes.add(new DefaultArtifactType("ear", "ear", "", "java", false, true));
- stereotypes.add(new DefaultArtifactType("rar", "rar", "", "java", false, true));
- stereotypes.add(new DefaultArtifactType("par", "par", "", "java", false, true));
- return stereotypes;
- }
-
- protected ArtifactDescriptorPolicy getArtifactDescriptorPolicy() {
- return new SimpleArtifactDescriptorPolicy(true, true);
- }
-
- /**
- * Creates a new Maven-like repository system session by initializing the session with values typical for
- * Maven-based resolution. In more detail, this method configures settings relevant for the processing of dependency
- * graphs, most other settings remain at their generic default value. Use the various setters to further configure
- * the session with authentication, mirror, proxy and other information required for your environment. At least,
- * local repository manager needs to be configured to make session be able to create session instance.
- *
- * @return SessionBuilder configured with minimally required things for "Maven-based resolution". At least LRM must
- * be set on builder to make it able to create session instances.
- */
- @Override
- public SessionBuilder get() {
- SessionBuilder builder = repositorySystem.createSessionBuilder();
- configureSessionBuilder(builder);
- return builder;
- }
-}
diff --git a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/scopes/Maven3ScopeManagerConfiguration.java b/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/scopes/Maven3ScopeManagerConfiguration.java
deleted file mode 100644
index 2cd55b6fa43a..000000000000
--- a/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/scopes/Maven3ScopeManagerConfiguration.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.apache.maven.repository.internal.scopes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.stream.Collectors;
-
-import org.eclipse.aether.artifact.ArtifactProperties;
-import org.eclipse.aether.impl.scope.BuildScopeMatrixSource;
-import org.eclipse.aether.impl.scope.BuildScopeSource;
-import org.eclipse.aether.impl.scope.CommonBuilds;
-import org.eclipse.aether.impl.scope.InternalScopeManager;
-import org.eclipse.aether.impl.scope.ScopeManagerConfiguration;
-import org.eclipse.aether.internal.impl.scope.ScopeManagerDump;
-import org.eclipse.aether.scope.DependencyScope;
-import org.eclipse.aether.scope.ResolutionScope;
-import org.eclipse.aether.util.artifact.JavaScopes;
-
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.all;
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.byBuildPath;
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.byProjectPath;
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.select;
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.singleton;
-import static org.eclipse.aether.impl.scope.BuildScopeQuery.union;
-
-/**
- * Maven3 scope configurations. Configures scope manager to support Maven3 scopes.
- *
- * This manager supports the old Maven 3 dependency scopes.
- *
- * Note: Maven3 CANNOT support Maven 4 scopes "test-only" and "test-runtime", as it does not distinguish
- * resolution scope (the class {@code ResolutionScope} has only "TEST", instead of "TEST_COMPILE" and "TEST_RUNTIME").
- * This scope manager configuration is not used in Maven 3!
- *
- * @since 3.10.0
- */
-public final class Maven3ScopeManagerConfiguration implements ScopeManagerConfiguration {
- public static final Maven3ScopeManagerConfiguration INSTANCE = new Maven3ScopeManagerConfiguration();
- public static final String DS_NONE = "none";
- public static final String DS_COMPILE = JavaScopes.COMPILE;
- public static final String DS_RUNTIME = JavaScopes.RUNTIME;
- public static final String DS_PROVIDED = JavaScopes.PROVIDED;
- public static final String DS_SYSTEM = JavaScopes.SYSTEM;
- public static final String DS_TEST = JavaScopes.TEST;
-
- public static final String RS_NONE = "none";
- public static final String RS_MAIN_COMPILE = "main-compile";
- public static final String RS_MAIN_COMPILE_PLUS_RUNTIME = "main-compilePlusRuntime";
- public static final String RS_MAIN_RUNTIME = "main-runtime";
- public static final String RS_MAIN_RUNTIME_PLUS_SYSTEM = "main-runtimePlusSystem";
- public static final String RS_TEST_COMPILE = "test-compile";
- public static final String RS_TEST_RUNTIME = "test-runtime";
-
- private Maven3ScopeManagerConfiguration() {}
-
- @Override
- public String getId() {
- return "Maven3";
- }
-
- @Override
- public boolean isStrictDependencyScopes() {
- return false;
- }
-
- @Override
- public boolean isStrictResolutionScopes() {
- return false;
- }
-
- @Override
- public BuildScopeSource getBuildScopeSource() {
- return new BuildScopeMatrixSource(
- Arrays.asList(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.PROJECT_PATH_TEST),
- Arrays.asList(CommonBuilds.BUILD_PATH_COMPILE, CommonBuilds.BUILD_PATH_RUNTIME),
- CommonBuilds.MAVEN_TEST_BUILD_SCOPE);
- }
-
- @Override
- public Collection buildDependencyScopes(InternalScopeManager internalScopeManager) {
- ArrayList result = new ArrayList<>();
- result.add(internalScopeManager.createDependencyScope(DS_NONE, false, Collections.emptySet()));
- result.add(internalScopeManager.createDependencyScope(DS_COMPILE, true, all()));
- result.add(internalScopeManager.createDependencyScope(
- DS_RUNTIME, true, byBuildPath(CommonBuilds.BUILD_PATH_RUNTIME)));
- result.add(internalScopeManager.createDependencyScope(
- DS_PROVIDED,
- false,
- union(
- byBuildPath(CommonBuilds.BUILD_PATH_COMPILE),
- select(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_RUNTIME))));
- result.add(internalScopeManager.createDependencyScope(
- DS_TEST, false, byProjectPath(CommonBuilds.PROJECT_PATH_TEST)));
- result.add(internalScopeManager.createSystemDependencyScope(
- DS_SYSTEM, false, all(), ArtifactProperties.LOCAL_PATH));
- return result;
- }
-
- @Override
- public Collection buildResolutionScopes(InternalScopeManager internalScopeManager) {
- Collection allDependencyScopes = internalScopeManager.getDependencyScopeUniverse();
- Collection nonTransitiveDependencyScopes =
- allDependencyScopes.stream().filter(s -> !s.isTransitive()).collect(Collectors.toSet());
- DependencyScope system =
- internalScopeManager.getDependencyScope(DS_SYSTEM).orElse(null);
-
- ArrayList result = new ArrayList<>();
- result.add(internalScopeManager.createResolutionScope(
- RS_NONE,
- InternalScopeManager.Mode.REMOVE,
- Collections.emptySet(),
- Collections.emptySet(),
- allDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_MAIN_COMPILE,
- InternalScopeManager.Mode.ELIMINATE,
- singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_COMPILE),
- Collections.singletonList(system),
- nonTransitiveDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_MAIN_COMPILE_PLUS_RUNTIME,
- InternalScopeManager.Mode.ELIMINATE,
- byProjectPath(CommonBuilds.PROJECT_PATH_MAIN),
- Collections.singletonList(system),
- nonTransitiveDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_MAIN_RUNTIME,
- InternalScopeManager.Mode.ELIMINATE,
- singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_RUNTIME),
- Collections.emptySet(),
- nonTransitiveDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_MAIN_RUNTIME_PLUS_SYSTEM,
- InternalScopeManager.Mode.ELIMINATE,
- singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_RUNTIME),
- Collections.singletonList(system),
- nonTransitiveDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_TEST_COMPILE,
- InternalScopeManager.Mode.ELIMINATE,
- select(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_COMPILE),
- Collections.singletonList(system),
- nonTransitiveDependencyScopes));
- result.add(internalScopeManager.createResolutionScope(
- RS_TEST_RUNTIME,
- InternalScopeManager.Mode.ELIMINATE,
- select(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_RUNTIME),
- Collections.singletonList(system),
- nonTransitiveDependencyScopes));
- return result;
- }
-
- // ===
-
- public static void main(String... args) {
- ScopeManagerDump.dump(Maven3ScopeManagerConfiguration.INSTANCE);
- }
-}
diff --git a/pom.xml b/pom.xml
index 692150ce703b..1e8cd5b79ee2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -422,6 +422,12 @@ under the License.
org.apache.maven.resolver
maven-resolver-supplier-mvn3
${resolverVersion}
+
+
+ *
+ *
+
+