Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions maven-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ under the License.
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-supplier-mvn3</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.internal.RepositorySystemSessionFactory;
import org.apache.maven.model.ModelBase;
import org.apache.maven.repository.supplier.SessionBuilderSupplier;
import org.apache.maven.rtinfo.RuntimeInformation;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy;
Expand All @@ -64,7 +65,6 @@
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.supplier.SessionBuilderSupplier;
import org.eclipse.aether.util.ConfigUtils;
import org.eclipse.aether.util.graph.manager.TransitiveDependencyManager;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
Expand Down
25 changes: 9 additions & 16 deletions maven-resolver-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-supplier-mvn3</artifactId>
<artifactId>maven-resolver-connector-basic</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-apache</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down Expand Up @@ -103,21 +111,6 @@ under the License.
<optional>true</optional>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-file</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-apache</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Set;

import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuilderFactory;
import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.FileModelSource;
import org.apache.maven.model.building.ModelBuilder;
Expand Down Expand Up @@ -70,8 +69,6 @@
import org.eclipse.aether.resolution.VersionRequest;
import org.eclipse.aether.resolution.VersionResolutionException;
import org.eclipse.aether.resolution.VersionResult;
import org.eclipse.aether.spi.locator.Service;
import org.eclipse.aether.spi.locator.ServiceLocator;
import org.eclipse.aether.transfer.ArtifactNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -81,7 +78,7 @@
*/
@Named
@Singleton
public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader, Service {
public class DefaultArtifactDescriptorReader implements ArtifactDescriptorReader {
private RemoteRepositoryManager remoteRepositoryManager;

private VersionResolver versionResolver;
Expand Down Expand Up @@ -188,20 +185,6 @@ public DefaultArtifactDescriptorReader(
setArtifactDescriptorDecorators(artifactDescriptorDecorators);
}

@Deprecated
public void initService(ServiceLocator locator) {
setRemoteRepositoryManager(locator.getService(RemoteRepositoryManager.class));
setVersionResolver(locator.getService(VersionResolver.class));
setVersionRangeResolver(locator.getService(VersionRangeResolver.class));
setArtifactResolver(locator.getService(ArtifactResolver.class));
modelBuilder = locator.getService(ModelBuilder.class);
if (modelBuilder == null) {
setModelBuilder(new DefaultModelBuilderFactory().newInstance());
}
setRepositoryEventDispatcher(locator.getService(RepositoryEventDispatcher.class));
setModelCacheFactory(locator.getService(ModelCacheFactory.class));
}

public DefaultArtifactDescriptorReader setRemoteRepositoryManager(RemoteRepositoryManager remoteRepositoryManager) {
this.remoteRepositoryManager =
Objects.requireNonNull(remoteRepositoryManager, "remoteRepositoryManager cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
import org.eclipse.aether.resolution.VersionRangeRequest;
import org.eclipse.aether.resolution.VersionRangeResolutionException;
import org.eclipse.aether.resolution.VersionRangeResult;
import org.eclipse.aether.spi.locator.Service;
import org.eclipse.aether.spi.locator.ServiceLocator;
import org.eclipse.aether.spi.synccontext.SyncContextFactory;
import org.eclipse.aether.util.ConfigUtils;
import org.eclipse.aether.util.version.GenericVersionScheme;
Expand All @@ -70,7 +68,7 @@
*/
@Named
@Singleton
public class DefaultVersionRangeResolver implements VersionRangeResolver, Service {
public class DefaultVersionRangeResolver implements VersionRangeResolver {
/**
* Configuration property for version range resolution used metadata {@link Metadata.Nature}.
* It may contain string names of {@link Metadata.Nature} enum values, or string value {@code "auto"}
Expand Down Expand Up @@ -105,13 +103,6 @@ public DefaultVersionRangeResolver(
setRepositoryEventDispatcher(repositoryEventDispatcher);
}

@Deprecated
public void initService(ServiceLocator locator) {
setMetadataResolver(locator.getService(MetadataResolver.class));
setSyncContextFactory(locator.getService(SyncContextFactory.class));
setRepositoryEventDispatcher(locator.getService(RepositoryEventDispatcher.class));
}

public DefaultVersionRangeResolver setMetadataResolver(MetadataResolver metadataResolver) {
this.metadataResolver = Objects.requireNonNull(metadataResolver, "metadataResolver cannot be null");
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
import org.eclipse.aether.resolution.VersionRequest;
import org.eclipse.aether.resolution.VersionResolutionException;
import org.eclipse.aether.resolution.VersionResult;
import org.eclipse.aether.spi.locator.Service;
import org.eclipse.aether.spi.locator.ServiceLocator;
import org.eclipse.aether.spi.synccontext.SyncContextFactory;
import org.eclipse.aether.util.ConfigUtils;

Expand All @@ -70,7 +68,7 @@
*/
@Named
@Singleton
public class DefaultVersionResolver implements VersionResolver, Service {
public class DefaultVersionResolver implements VersionResolver {

private static final String MAVEN_METADATA_XML = "maven-metadata.xml";

Expand Down Expand Up @@ -101,13 +99,6 @@ public DefaultVersionResolver(
setRepositoryEventDispatcher(repositoryEventDispatcher);
}

@Deprecated
public void initService(ServiceLocator locator) {
setMetadataResolver(locator.getService(MetadataResolver.class));
setSyncContextFactory(locator.getService(SyncContextFactory.class));
setRepositoryEventDispatcher(locator.getService(RepositoryEventDispatcher.class));
}

public DefaultVersionResolver setMetadataResolver(MetadataResolver metadataResolver) {
this.metadataResolver = Objects.requireNonNull(metadataResolver, "metadataResolver cannot be null");
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
* 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.supplier;

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.
* <p>
* This manager supports the old Maven 3 dependency scopes + new scopes.
* <p>
* Note: Maven3 CANNOT support new 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").
* <em>This scope manager configuration is not used in Maven 3!</em>
*
* @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 DS_COMPILE_ONLY = "compile-only";
public static final String DS_TEST_ONLY = "test-only";
public static final String DS_TEST_RUNTIME = "test-runtime";

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 = "test";
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<DependencyScope> buildDependencyScopes(InternalScopeManager internalScopeManager) {
ArrayList<DependencyScope> 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_COMPILE_ONLY, false, select(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_COMPILE)));
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.createDependencyScope(
DS_TEST_ONLY, false, singleton(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_COMPILE)));
result.add(internalScopeManager.createDependencyScope(
DS_TEST_RUNTIME, false, singleton(CommonBuilds.PROJECT_PATH_TEST, CommonBuilds.BUILD_PATH_RUNTIME)));
result.add(internalScopeManager.createSystemDependencyScope(
DS_SYSTEM, false, all(), ArtifactProperties.LOCAL_PATH));
return result;
}

@Override
public Collection<ResolutionScope> buildResolutionScopes(InternalScopeManager internalScopeManager) {
Collection<DependencyScope> allDependencyScopes = internalScopeManager.getDependencyScopeUniverse();
Collection<DependencyScope> nonTransitiveDependencyScopes =
allDependencyScopes.stream().filter(s -> !s.isTransitive()).collect(Collectors.toSet());
DependencyScope system =
internalScopeManager.getDependencyScope(DS_SYSTEM).orElse(null);

ArrayList<ResolutionScope> result = new ArrayList<>();
result.add(internalScopeManager.createResolutionScope(
RS_NONE,
InternalScopeManager.Mode.REMOVE,
Collections.emptySet(),
Collections.emptySet(),
allDependencyScopes));
result.add(internalScopeManager.createResolutionScope(
RS_MAIN_COMPILE,
Collections.singleton("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,
Collections.singleton("compile+runtime"),
InternalScopeManager.Mode.ELIMINATE,
byProjectPath(CommonBuilds.PROJECT_PATH_MAIN),
Collections.singletonList(system),
nonTransitiveDependencyScopes));
result.add(internalScopeManager.createResolutionScope(
RS_MAIN_RUNTIME,
Collections.singleton("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,
Collections.singleton("runtime+system"),
InternalScopeManager.Mode.ELIMINATE,
singleton(CommonBuilds.PROJECT_PATH_MAIN, CommonBuilds.BUILD_PATH_RUNTIME),
Collections.singletonList(system),
nonTransitiveDependencyScopes));
result.add(internalScopeManager.createResolutionScope(
RS_TEST,
InternalScopeManager.Mode.ELIMINATE,
byProjectPath(CommonBuilds.PROJECT_PATH_TEST),
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);
}
}
Loading
Loading