[MNG-7794][MNG-7809] Deprecate RepositorySystem and make maven-compat optional (#1150)

* Move maven-compat to jsr330
* Remove more ties to RepositorySystem
* Move more stuff to maven-compat
* Move PluginManager and LocalRepositoryNotAccessibleException to maven-compat
* Fix tests
* Break circular dependency loop in components
* Move unused deprecated classes
This commit is contained in:
Guillaume Nodet 2023-06-15 16:24:56 +02:00 committed by GitHub
parent 00d350eaca
commit 967d8fc19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
123 changed files with 966 additions and 576 deletions

View File

@ -88,10 +88,6 @@ under the License.
<groupId>org.eclipse.sisu</groupId> <groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId> <artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId> <artifactId>wagon-provider-api</artifactId>
@ -127,8 +123,8 @@ under the License.
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.plexus</groupId> <groupId>org.eclipse.sisu</groupId>
<artifactId>plexus-component-metadata</artifactId> <artifactId>sisu-maven-plugin</artifactId>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.modello</groupId> <groupId>org.codehaus.modello</groupId>

View File

@ -25,6 +25,7 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
/** /**
* ArtifactFilterManager * ArtifactFilterManager
*/ */
@Deprecated
public interface ArtifactFilterManager { public interface ArtifactFilterManager {
/** /**
* Returns a filter for core + extension artifacts. * Returns a filter for core + extension artifacts.

View File

@ -23,6 +23,7 @@ import java.util.Set;
/** /**
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core extensions. * @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core extensions.
*/ */
@Deprecated
public interface ArtifactFilterManagerDelegate { public interface ArtifactFilterManagerDelegate {
void addExcludes(Set<String> excludes); void addExcludes(Set<String> excludes);

View File

@ -35,7 +35,7 @@ import org.apache.maven.extension.internal.CoreExports;
*/ */
@Named @Named
@Singleton @Singleton
@SuppressWarnings("deprecation") @Deprecated
public class DefaultArtifactFilterManager implements ArtifactFilterManager { public class DefaultArtifactFilterManager implements ArtifactFilterManager {
// this is a live injected collection // this is a live injected collection

View File

@ -48,9 +48,9 @@ import org.apache.maven.repository.RepositorySystem;
* but should have been. * but should have been.
* *
*/ */
@Deprecated
@Named @Named
@Singleton @Singleton
@Deprecated
public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver { public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver {
private final RepositorySystem repositorySystem; private final RepositorySystem repositorySystem;

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.artifact.deployer; package org.apache.maven.artifact.deployer;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -33,8 +36,6 @@ import org.apache.maven.artifact.repository.metadata.MetadataBridge;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
@ -49,13 +50,13 @@ import org.eclipse.aether.util.artifact.SubArtifact;
/** /**
* DefaultArtifactDeployer * DefaultArtifactDeployer
*/ */
@Component(role = ArtifactDeployer.class, instantiationStrategy = "per-lookup") @Named
public class DefaultArtifactDeployer extends AbstractLogEnabled implements ArtifactDeployer { public class DefaultArtifactDeployer extends AbstractLogEnabled implements ArtifactDeployer {
@Requirement @Inject
private RepositorySystem repoSystem; private RepositorySystem repoSystem;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<>(); private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<>();

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.artifact.installer; package org.apache.maven.artifact.installer;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import org.apache.maven.RepositoryUtils; import org.apache.maven.RepositoryUtils;
@ -32,8 +36,6 @@ import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryM
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.artifact.ProjectArtifactMetadata; import org.apache.maven.project.artifact.ProjectArtifactMetadata;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
@ -45,13 +47,14 @@ import org.eclipse.aether.util.artifact.SubArtifact;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = ArtifactInstaller.class) @Named
@Singleton
public class DefaultArtifactInstaller extends AbstractLogEnabled implements ArtifactInstaller { public class DefaultArtifactInstaller extends AbstractLogEnabled implements ArtifactInstaller {
@Requirement @Inject
private RepositorySystem repoSystem; private RepositorySystem repoSystem;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
/** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ /** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.artifact.manager; package org.apache.maven.artifact.manager;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
@ -37,31 +41,30 @@ import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyInfo;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
/** /**
* Manages <a href="https://maven.apache.org/wagon">Wagon</a> related operations in Maven. * Manages <a href="https://maven.apache.org/wagon">Wagon</a> related operations in Maven.
*/ */
@Component(role = WagonManager.class) @Named
@Singleton
public class DefaultWagonManager extends org.apache.maven.repository.legacy.DefaultWagonManager public class DefaultWagonManager extends org.apache.maven.repository.legacy.DefaultWagonManager
implements WagonManager { implements WagonManager {
// NOTE: This must use a different field name than in the super class or IoC has no chance to inject the loggers // NOTE: This must use a different field name than in the super class or IoC has no chance to inject the loggers
@Requirement @Inject
private Logger log; private Logger log;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
@Requirement @Inject
private SettingsDecrypter settingsDecrypter; private SettingsDecrypter settingsDecrypter;
@Requirement @Inject
private MirrorSelector mirrorSelector; private MirrorSelector mirrorSelector;
@Requirement @Inject
private ArtifactRepositoryFactory artifactRepositoryFactory; private ArtifactRepositoryFactory artifactRepositoryFactory;
public AuthenticationInfo getAuthenticationInfo(String id) { public AuthenticationInfo getAuthenticationInfo(String id) {

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.artifact.repository; package org.apache.maven.artifact.repository;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -25,24 +29,25 @@ import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.RepositorySystemSession;
/** /**
* @author jdcasey * @author jdcasey
*/ */
@Component(role = ArtifactRepositoryFactory.class) @Named
@Singleton
public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory { public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory {
@Requirement @Inject
private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory; private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
@Requirement @Inject
private RepositorySystem repositorySystem; private PlexusContainer container;
public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException { public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException {
return factory.getLayout(layoutId); return factory.getLayout(layoutId);
@ -92,6 +97,13 @@ public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFacto
if (session != null && repository != null && !isLocalRepository(repository)) { if (session != null && repository != null && !isLocalRepository(repository)) {
List<ArtifactRepository> repositories = Arrays.asList(repository); List<ArtifactRepository> repositories = Arrays.asList(repository);
RepositorySystem repositorySystem;
try {
repositorySystem = container.lookup(RepositorySystem.class);
} catch (ComponentLookupException e) {
throw new IllegalStateException("Unable to lookup " + RepositorySystem.class.getName());
}
if (mirrors) { if (mirrors) {
repositorySystem.injectMirror(session, repositories); repositorySystem.injectMirror(session, repositories);
} }

View File

@ -60,6 +60,10 @@ public class LegacyLocalRepositoryManager implements LocalRepositoryManager {
public static RepositorySystemSession overlay( public static RepositorySystemSession overlay(
ArtifactRepository repository, RepositorySystemSession session, RepositorySystem system) { ArtifactRepository repository, RepositorySystemSession session, RepositorySystem system) {
return overlay(repository, session);
}
public static RepositorySystemSession overlay(ArtifactRepository repository, RepositorySystemSession session) {
if (repository == null || repository.getBasedir() == null) { if (repository == null || repository.getBasedir() == null) {
return session; return session;
} }

View File

@ -18,16 +18,19 @@
*/ */
package org.apache.maven.artifact.repository.layout; package org.apache.maven.artifact.repository.layout;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* FlatRepositoryLayout * FlatRepositoryLayout
*/ */
@Component(role = ArtifactRepositoryLayout.class, hint = "flat") @Named("flat")
@Singleton
public class FlatRepositoryLayout implements ArtifactRepositoryLayout { public class FlatRepositoryLayout implements ArtifactRepositoryLayout {
private static final char ARTIFACT_SEPARATOR = '-'; private static final char ARTIFACT_SEPARATOR = '-';

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.artifact.repository.metadata; package org.apache.maven.artifact.repository.metadata;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -40,20 +44,19 @@ import org.apache.maven.repository.legacy.UpdateCheckManager;
import org.apache.maven.repository.legacy.WagonManager; import org.apache.maven.repository.legacy.WagonManager;
import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.TransferFailedException; import org.apache.maven.wagon.TransferFailedException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = RepositoryMetadataManager.class) @Named
@Singleton
public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager { public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager {
@Requirement @Inject
private WagonManager wagonManager; private WagonManager wagonManager;
@Requirement @Inject
private UpdateCheckManager updateCheckManager; private UpdateCheckManager updateCheckManager;
public void resolve( public void resolve(

View File

@ -18,13 +18,15 @@
*/ */
package org.apache.maven.artifact.resolver; package org.apache.maven.artifact.resolver;
import org.codehaus.plexus.component.annotations.Component; import javax.inject.Named;
import javax.inject.Singleton;
/** /**
* Artifact collector - takes a set of original artifacts and resolves all of the best versions to use * Artifact collector - takes a set of original artifacts and resolves all of the best versions to use
* along with their metadata. No artifacts are downloaded. * along with their metadata. No artifacts are downloaded.
*/ */
@Deprecated @Deprecated
@Component(role = ArtifactCollector.class) @Named
@Singleton
public class DefaultArtifactCollector extends org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector public class DefaultArtifactCollector extends org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector
implements ArtifactCollector {} implements ArtifactCollector {}

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.artifact.resolver; package org.apache.maven.artifact.resolver;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -55,8 +59,6 @@ import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable;
@ -69,32 +71,30 @@ import org.eclipse.aether.resolution.ArtifactResult;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = ArtifactResolver.class) @Named
@Singleton
public class DefaultArtifactResolver implements ArtifactResolver, Disposable { public class DefaultArtifactResolver implements ArtifactResolver, Disposable {
@Requirement @Inject
private Logger logger; private Logger logger;
@Requirement @Inject
protected ArtifactFactory artifactFactory; protected ArtifactFactory artifactFactory;
@Requirement @Inject
private ArtifactCollector artifactCollector; private ArtifactCollector artifactCollector;
@Requirement @Inject
private ResolutionErrorHandler resolutionErrorHandler; private ResolutionErrorHandler resolutionErrorHandler;
@Requirement @Inject
private ArtifactMetadataSource source; private ArtifactMetadataSource source;
@Requirement @Inject
private PlexusContainer container; private PlexusContainer container;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
@Requirement
private RepositorySystem repoSystem;
private final Executor executor; private final Executor executor;
public DefaultArtifactResolver() { public DefaultArtifactResolver() {
@ -108,7 +108,7 @@ public class DefaultArtifactResolver implements ArtifactResolver, Disposable {
} }
private RepositorySystemSession getSession(ArtifactRepository localRepository) { private RepositorySystemSession getSession(ArtifactRepository localRepository) {
return LegacyLocalRepositoryManager.overlay(localRepository, legacySupport.getRepositorySession(), repoSystem); return LegacyLocalRepositoryManager.overlay(localRepository, legacySupport.getRepositorySession(), null);
} }
private void injectSession1(RepositoryRequest request, MavenSession session) { private void injectSession1(RepositoryRequest request, MavenSession session) {
@ -185,7 +185,10 @@ public class DefaultArtifactResolver implements ArtifactResolver, Disposable {
String path = lrm.getPathForLocalArtifact(artifactRequest.getArtifact()); String path = lrm.getPathForLocalArtifact(artifactRequest.getArtifact());
artifact.setFile(new File(lrm.getRepository().getBasedir(), path)); artifact.setFile(new File(lrm.getRepository().getBasedir(), path));
RepositorySystem repoSystem = container.lookup(RepositorySystem.class);
result = repoSystem.resolveArtifact(session, artifactRequest); result = repoSystem.resolveArtifact(session, artifactRequest);
} catch (ComponentLookupException e) {
throw new IllegalStateException("Unable to lookup " + RepositorySystem.class.getName());
} catch (org.eclipse.aether.resolution.ArtifactResolutionException e) { } catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
if (e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException) { if (e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException) {
throw new ArtifactNotFoundException(e.getMessage(), artifact, remoteRepositories, e); throw new ArtifactNotFoundException(e.getMessage(), artifact, remoteRepositories, e);

View File

@ -18,10 +18,12 @@
*/ */
package org.apache.maven.execution; package org.apache.maven.execution;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@ -31,10 +33,11 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/ */
@Deprecated @Deprecated
@Component(role = RuntimeInformation.class) @Named
@Singleton
public class DefaultRuntimeInformation implements RuntimeInformation, Initializable { public class DefaultRuntimeInformation implements RuntimeInformation, Initializable {
@Requirement @Inject
private org.apache.maven.rtinfo.RuntimeInformation rtInfo; private org.apache.maven.rtinfo.RuntimeInformation rtInfo;
private ArtifactVersion applicationVersion; private ArtifactVersion applicationVersion;

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.maven.profiles; package org.apache.maven.profiles;
import javax.inject.Inject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -32,7 +34,6 @@ import org.apache.maven.model.profile.ProfileSelector;
import org.apache.maven.profiles.activation.ProfileActivationException; import org.apache.maven.profiles.activation.ProfileActivationException;
import org.codehaus.plexus.MutablePlexusContainer; import org.codehaus.plexus.MutablePlexusContainer;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
@ -42,10 +43,10 @@ import org.codehaus.plexus.logging.Logger;
@Deprecated @Deprecated
public class DefaultProfileManager implements ProfileManager { public class DefaultProfileManager implements ProfileManager {
@Requirement @Inject
private Logger logger; private Logger logger;
@Requirement @Inject
private ProfileSelector profileSelector; private ProfileSelector profileSelector;
private List<String> activatedIds = new ArrayList<>(); private List<String> activatedIds = new ArrayList<>();

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.project; package org.apache.maven.project;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -41,22 +45,21 @@ import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.properties.internal.EnvironmentUtils; import org.apache.maven.properties.internal.EnvironmentUtils;
import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
*/ */
@Component(role = MavenProjectBuilder.class)
@Deprecated @Deprecated
@Named
@Singleton
public class DefaultMavenProjectBuilder implements MavenProjectBuilder { public class DefaultMavenProjectBuilder implements MavenProjectBuilder {
@Requirement @Inject
private ProjectBuilder projectBuilder; private ProjectBuilder projectBuilder;
@Requirement @Inject
private RepositorySystem repositorySystem; private RepositorySystem repositorySystem;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@ -43,6 +43,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
*/ */
@Named @Named
@Singleton @Singleton
@Deprecated
public class DefaultMavenMetadataCache implements MavenMetadataCache { public class DefaultMavenMetadataCache implements MavenMetadataCache {
protected final Map<CacheKey, CacheRecord> cache = new ConcurrentHashMap<>(); protected final Map<CacheKey, CacheRecord> cache = new ConcurrentHashMap<>();

View File

@ -37,6 +37,7 @@ import org.apache.maven.project.ProjectBuilder;
*/ */
@Named @Named
@Singleton @Singleton
@Deprecated
public class DefaultMetadataSource extends MavenMetadataSource { public class DefaultMetadataSource extends MavenMetadataSource {
@Inject @Inject
public DefaultMetadataSource( public DefaultMetadataSource(

View File

@ -27,6 +27,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
/** /**
* MavenMetadataCache * MavenMetadataCache
*/ */
@Deprecated
public interface MavenMetadataCache { public interface MavenMetadataCache {
ResolutionGroup get( ResolutionGroup get(

View File

@ -92,6 +92,7 @@ import org.slf4j.LoggerFactory;
*/ */
@Named("maven") @Named("maven")
@Singleton @Singleton
@Deprecated
public class MavenMetadataSource implements ArtifactMetadataSource { public class MavenMetadataSource implements ArtifactMetadataSource {
private final Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
private final RepositoryMetadataManager repositoryMetadataManager; private final RepositoryMetadataManager repositoryMetadataManager;

View File

@ -33,6 +33,7 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataStoreExce
* *
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/ */
@Deprecated
public class ProjectArtifactMetadata extends AbstractArtifactMetadata { public class ProjectArtifactMetadata extends AbstractArtifactMetadata {
private final File file; private final File file;

View File

@ -18,14 +18,17 @@
*/ */
package org.apache.maven.project.inheritance; package org.apache.maven.project.inheritance;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* DefaultModelInheritanceAssembler * DefaultModelInheritanceAssembler
*/ */
@Component(role = ModelInheritanceAssembler.class) @Named
@Singleton
public class DefaultModelInheritanceAssembler implements ModelInheritanceAssembler { public class DefaultModelInheritanceAssembler implements ModelInheritanceAssembler {
@Override @Override
public void assembleModelInheritance(Model child, Model parent, String childPathAdjustment) { public void assembleModelInheritance(Model child, Model parent, String childPathAdjustment) {

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.maven.project.interpolation; package org.apache.maven.project.interpolation;
import javax.inject.Inject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
@ -35,7 +37,6 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.path.PathTranslator; import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.interpolation.AbstractValueSource; import org.codehaus.plexus.interpolation.AbstractValueSource;
import org.codehaus.plexus.interpolation.InterpolationException; import org.codehaus.plexus.interpolation.InterpolationException;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
@ -86,7 +87,7 @@ public abstract class AbstractStringBasedModelInterpolator extends AbstractLogEn
TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes; TRANSLATED_PATH_EXPRESSIONS = translatedPrefixes;
} }
@Requirement @Inject
private PathTranslator pathTranslator; private PathTranslator pathTranslator;
private Interpolator interpolator; private Interpolator interpolator;

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.project.interpolation; package org.apache.maven.project.interpolation;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -33,7 +36,6 @@ import java.util.WeakHashMap;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.path.PathTranslator; import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor; import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.Interpolator; import org.codehaus.plexus.interpolation.Interpolator;
import org.codehaus.plexus.interpolation.StringSearchInterpolator; import org.codehaus.plexus.interpolation.StringSearchInterpolator;
@ -44,7 +46,8 @@ import org.codehaus.plexus.logging.Logger;
* StringSearchModelInterpolator * StringSearchModelInterpolator
*/ */
@Deprecated @Deprecated
@Component(role = ModelInterpolator.class) @Named
@Singleton
public class StringSearchModelInterpolator extends AbstractStringBasedModelInterpolator { public class StringSearchModelInterpolator extends AbstractStringBasedModelInterpolator {
private static final Map<Class<?>, Field[]> FIELDS_BY_CLASS = new WeakHashMap<>(); private static final Map<Class<?>, Field[]> FIELDS_BY_CLASS = new WeakHashMap<>();

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.project.path; package org.apache.maven.project.path;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -26,13 +29,13 @@ import org.apache.maven.model.Build;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Reporting; import org.apache.maven.model.Reporting;
import org.apache.maven.model.Resource; import org.apache.maven.model.Resource;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* DefaultPathTranslator * DefaultPathTranslator
*/ */
@Deprecated @Deprecated
@Component(role = PathTranslator.class) @Named
@Singleton
public class DefaultPathTranslator implements PathTranslator { public class DefaultPathTranslator implements PathTranslator {
private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}", "${project.basedir}"}; private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}", "${project.basedir}"};

View File

@ -18,23 +18,26 @@
*/ */
package org.apache.maven.project.validation; package org.apache.maven.project.validation;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.DefaultModelBuildingRequest;
import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest;
import org.apache.maven.model.building.ModelProblem; import org.apache.maven.model.building.ModelProblem;
import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a> * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/ */
@Component(role = ModelValidator.class)
@Deprecated @Deprecated
@Named
@Singleton
public class DefaultModelValidator implements ModelValidator { public class DefaultModelValidator implements ModelValidator {
@Requirement @Inject
private org.apache.maven.model.validation.ModelValidator modelValidator; private org.apache.maven.model.validation.ModelValidator modelValidator;
public ModelValidationResult validate(Model model) { public ModelValidationResult validate(Model model) {

View File

@ -21,6 +21,7 @@ package org.apache.maven.repository;
/** /**
* ArtifactDoesNotExistException * ArtifactDoesNotExistException
*/ */
@Deprecated
public class ArtifactDoesNotExistException extends Exception { public class ArtifactDoesNotExistException extends Exception {
public ArtifactDoesNotExistException(final String message) { public ArtifactDoesNotExistException(final String message) {
super(message); super(message);

View File

@ -27,6 +27,7 @@ import java.util.EventObject;
* *
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*/ */
@Deprecated
public class ArtifactTransferEvent extends EventObject { public class ArtifactTransferEvent extends EventObject {
/** /**
* A transfer was attempted, but has not yet commenced. * A transfer was attempted, but has not yet commenced.

View File

@ -21,6 +21,7 @@ package org.apache.maven.repository;
/** /**
* ArtifactTransferFailedException * ArtifactTransferFailedException
*/ */
@Deprecated
public class ArtifactTransferFailedException extends Exception { public class ArtifactTransferFailedException extends Exception {
public ArtifactTransferFailedException(final String message) { public ArtifactTransferFailedException(final String message) {
super(message); super(message);

View File

@ -21,6 +21,7 @@ package org.apache.maven.repository;
/** /**
* ArtifactTransferListener * ArtifactTransferListener
*/ */
@Deprecated
public interface ArtifactTransferListener { public interface ArtifactTransferListener {
boolean isShowChecksumEvents(); boolean isShowChecksumEvents();

View File

@ -23,6 +23,7 @@ package org.apache.maven.repository;
* *
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Deprecated
public interface ArtifactTransferResource { public interface ArtifactTransferResource {
/** /**

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.repository; package org.apache.maven.repository;
import javax.inject.Named;
import javax.inject.Singleton;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
@ -25,12 +28,12 @@ import java.util.List;
import org.apache.maven.RepositoryUtils; import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* DefaultMirrorSelector * DefaultMirrorSelector
*/ */
@Component(role = MirrorSelector.class) @Named
@Singleton
public class DefaultMirrorSelector implements MirrorSelector { public class DefaultMirrorSelector implements MirrorSelector {
private static final String WILDCARD = "*"; private static final String WILDCARD = "*";

View File

@ -24,6 +24,7 @@ import org.apache.maven.artifact.repository.MavenArtifactRepository;
/** /**
* LocalArtifactRepository * LocalArtifactRepository
*/ */
@Deprecated
public abstract class LocalArtifactRepository extends MavenArtifactRepository { public abstract class LocalArtifactRepository extends MavenArtifactRepository {
public static final String IDE_WORKSPACE = "ide-workspace"; public static final String IDE_WORKSPACE = "ide-workspace";

View File

@ -25,6 +25,7 @@ import java.io.IOException;
* *
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Deprecated
public class LocalRepositoryNotAccessibleException extends IOException { public class LocalRepositoryNotAccessibleException extends IOException {
public LocalRepositoryNotAccessibleException(String message, Throwable cause) { public LocalRepositoryNotAccessibleException(String message, Throwable cause) {

View File

@ -28,6 +28,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
@ -38,9 +39,11 @@ import org.eclipse.aether.RepositorySystemSession;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
* @since 3.0-alpha * @since 3.0-alpha
* @deprecated Use {@link MavenRepositorySystem} if needed, or maven-resolver directly, until maven 4.x api is out
*/ */
@Deprecated
public interface RepositorySystem { public interface RepositorySystem {
String DEFAULT_LOCAL_REPO_ID = "local"; String DEFAULT_LOCAL_REPO_ID = MavenRepositorySystem.DEFAULT_LOCAL_REPO_ID;
@SuppressWarnings("checkstyle:constantname") @SuppressWarnings("checkstyle:constantname")
String userHome = System.getProperty("user.home"); String userHome = System.getProperty("user.home");
@ -51,9 +54,9 @@ public interface RepositorySystem {
@SuppressWarnings("checkstyle:constantname") @SuppressWarnings("checkstyle:constantname")
File defaultUserLocalRepository = new File(userMavenConfigurationHome, "repository"); File defaultUserLocalRepository = new File(userMavenConfigurationHome, "repository");
String DEFAULT_REMOTE_REPO_ID = "central"; String DEFAULT_REMOTE_REPO_ID = MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID;
String DEFAULT_REMOTE_REPO_URL = "https://repo.maven.apache.org/maven2"; String DEFAULT_REMOTE_REPO_URL = MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID;
Artifact createArtifact(String groupId, String artifactId, String version, String packaging); Artifact createArtifact(String groupId, String artifactId, String version, String packaging);

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.repository.legacy; package org.apache.maven.repository.legacy;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
@ -34,14 +37,14 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.artifact.repository.Authentication;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.repository.Proxy; import org.apache.maven.repository.Proxy;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
/** /**
* DefaultUpdateCheckManager * DefaultUpdateCheckManager
*/ */
@Component(role = UpdateCheckManager.class) @Named
@Singleton
public class DefaultUpdateCheckManager extends AbstractLogEnabled implements UpdateCheckManager { public class DefaultUpdateCheckManager extends AbstractLogEnabled implements UpdateCheckManager {
private static final String ERROR_KEY_SUFFIX = ".error"; private static final String ERROR_KEY_SUFFIX = ".error";

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.repository.legacy; package org.apache.maven.repository.legacy;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -46,8 +50,6 @@ import org.apache.maven.wagon.observers.ChecksumObserver;
import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository; import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
@ -62,7 +64,8 @@ import org.eclipse.aether.util.ConfigUtils;
/** /**
* Manages <a href="https://maven.apache.org/wagon">Wagon</a> related operations in Maven. * Manages <a href="https://maven.apache.org/wagon">Wagon</a> related operations in Maven.
*/ */
@Component(role = WagonManager.class) @Named
@Singleton
public class DefaultWagonManager implements WagonManager { public class DefaultWagonManager implements WagonManager {
private static final String[] CHECKSUM_IDS = {"md5", "sha1"}; private static final String[] CHECKSUM_IDS = {"md5", "sha1"};
@ -72,16 +75,16 @@ public class DefaultWagonManager implements WagonManager {
*/ */
private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"}; private static final String[] CHECKSUM_ALGORITHMS = {"MD5", "SHA-1"};
@Requirement @Inject
private Logger logger; private Logger logger;
@Requirement @Inject
private PlexusContainer container; private PlexusContainer container;
@Requirement @Inject
private UpdateCheckManager updateCheckManager; private UpdateCheckManager updateCheckManager;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
// //

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.repository.legacy; package org.apache.maven.repository.legacy;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -67,8 +71,6 @@ import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.proxy.ProxyUtils; import org.apache.maven.wagon.proxy.ProxyUtils;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
@ -81,34 +83,35 @@ import org.eclipse.aether.repository.RemoteRepository;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = RepositorySystem.class, hint = "default") @Named("default")
@Singleton
public class LegacyRepositorySystem implements RepositorySystem { public class LegacyRepositorySystem implements RepositorySystem {
@Requirement @Inject
private Logger logger; private Logger logger;
@Requirement @Inject
private ArtifactFactory artifactFactory; private ArtifactFactory artifactFactory;
@Requirement @Inject
private ArtifactResolver artifactResolver; private ArtifactResolver artifactResolver;
@Requirement @Inject
private ArtifactRepositoryFactory artifactRepositoryFactory; private ArtifactRepositoryFactory artifactRepositoryFactory;
@Requirement(role = ArtifactRepositoryLayout.class) @Inject
private Map<String, ArtifactRepositoryLayout> layouts; private Map<String, ArtifactRepositoryLayout> layouts;
@Requirement @Inject
private WagonManager wagonManager; private WagonManager wagonManager;
@Requirement @Inject
private PlexusContainer plexus; private PlexusContainer plexus;
@Requirement @Inject
private MirrorSelector mirrorSelector; private MirrorSelector mirrorSelector;
@Requirement @Inject
private SettingsDecrypter settingsDecrypter; private SettingsDecrypter settingsDecrypter;
public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) { public Artifact createArtifact(String groupId, String artifactId, String version, String scope, String type) {

View File

@ -25,6 +25,7 @@ import org.apache.maven.artifact.Artifact;
* *
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/ */
@Deprecated
public abstract class AbstractArtifactMetadata implements ArtifactMetadata { public abstract class AbstractArtifactMetadata implements ArtifactMetadata {
private static final String LS = System.lineSeparator(); private static final String LS = System.lineSeparator();

View File

@ -25,6 +25,7 @@ import org.apache.maven.artifact.Artifact;
* *
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*/ */
@Deprecated
public class ArtifactMetadataRetrievalException extends Exception { public class ArtifactMetadataRetrievalException extends Exception {
private Artifact artifact; private Artifact artifact;

View File

@ -30,6 +30,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion;
* *
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
*/ */
@Deprecated
public interface ArtifactMetadataSource { public interface ArtifactMetadataSource {
ResolutionGroup retrieve(MetadataResolutionRequest request) throws ArtifactMetadataRetrievalException; ResolutionGroup retrieve(MetadataResolutionRequest request) throws ArtifactMetadataRetrievalException;

View File

@ -31,6 +31,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
* *
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Deprecated
public class DefaultMetadataResolutionRequest implements MetadataResolutionRequest { public class DefaultMetadataResolutionRequest implements MetadataResolutionRequest {
private Artifact artifact; private Artifact artifact;

View File

@ -29,6 +29,7 @@ import org.apache.maven.artifact.repository.RepositoryRequest;
* *
* @author Benjamin Bentmann * @author Benjamin Bentmann
*/ */
@Deprecated
public interface MetadataResolutionRequest extends RepositoryRequest { public interface MetadataResolutionRequest extends RepositoryRequest {
/** /**

View File

@ -28,6 +28,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
/** /**
* ResolutionGroup * ResolutionGroup
*/ */
@Deprecated
public class ResolutionGroup { public class ResolutionGroup {
private final Set<Artifact> artifacts; private final Set<Artifact> artifacts;

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.repository.legacy.repository; package org.apache.maven.repository.legacy.repository;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.Map; import java.util.Map;
import org.apache.maven.artifact.UnknownRepositoryLayoutException; import org.apache.maven.artifact.UnknownRepositoryLayoutException;
@ -26,20 +30,19 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.MavenArtifactRepository; import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout2;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
* @author jdcasey * @author jdcasey
*/ */
@Component(role = ArtifactRepositoryFactory.class) @Named
@Singleton
public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory { public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory {
// TODO use settings? // TODO use settings?
private String globalUpdatePolicy; private String globalUpdatePolicy;
private String globalChecksumPolicy; private String globalChecksumPolicy;
@Requirement(role = ArtifactRepositoryLayout.class) @Inject
private Map<String, ArtifactRepositoryLayout> repositoryLayouts; private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException { public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException {

View File

@ -18,6 +18,10 @@
*/ */
package org.apache.maven.repository.legacy.resolver; package org.apache.maven.repository.legacy.resolver;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -50,24 +54,24 @@ import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalExce
import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.DefaultMetadataResolutionRequest;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
/** /**
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = LegacyArtifactCollector.class) @Named
@Singleton
public class DefaultLegacyArtifactCollector implements LegacyArtifactCollector { public class DefaultLegacyArtifactCollector implements LegacyArtifactCollector {
@Requirement(hint = "nearest") @Inject
@Named("nearest")
private ConflictResolver defaultConflictResolver; private ConflictResolver defaultConflictResolver;
@Requirement @Inject
private Logger logger; private Logger logger;
@Requirement @Inject
private LegacySupport legacySupport; private LegacySupport legacySupport;
private void injectSession(ArtifactResolutionRequest request) { private void injectSession(ArtifactResolutionRequest request) {

View File

@ -18,7 +18,8 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import org.codehaus.plexus.component.annotations.Component; import javax.inject.Named;
import javax.inject.Singleton;
/** /**
* The default conflict resolver that delegates to the nearest strategy. * The default conflict resolver that delegates to the nearest strategy.
@ -28,5 +29,6 @@ import org.codehaus.plexus.component.annotations.Component;
* @deprecated As of 3.0, use a specific implementation instead, e.g. {@link NearestConflictResolver} * @deprecated As of 3.0, use a specific implementation instead, e.g. {@link NearestConflictResolver}
*/ */
@Deprecated @Deprecated
@Component(role = ConflictResolver.class) @Named
@Singleton
public class DefaultConflictResolver extends NearestConflictResolver {} public class DefaultConflictResolver extends NearestConflictResolver {}

View File

@ -18,10 +18,12 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.context.ContextException;
@ -34,14 +36,15 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
* TODO you don't need the container in here with the active maps (jvz). * TODO you don't need the container in here with the active maps (jvz).
* @since 3.0 * @since 3.0
*/ */
@Component(role = ConflictResolverFactory.class) @Named
@Singleton
public class DefaultConflictResolverFactory implements ConflictResolverFactory, Contextualizable { public class DefaultConflictResolverFactory implements ConflictResolverFactory, Contextualizable {
// fields ----------------------------------------------------------------- // fields -----------------------------------------------------------------
/** /**
* The plexus container used to obtain instances from. * The plexus container used to obtain instances from.
*/ */
@Requirement @Inject
private PlexusContainer container; private PlexusContainer container;
// ConflictResolverFactory methods ---------------------------------------- // ConflictResolverFactory methods ----------------------------------------

View File

@ -18,8 +18,10 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Resolves conflicting artifacts by always selecting the <em>farthest</em> declaration. Farthest is defined as the * Resolves conflicting artifacts by always selecting the <em>farthest</em> declaration. Farthest is defined as the
@ -28,7 +30,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a> * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @since 3.0 * @since 3.0
*/ */
@Component(role = ConflictResolver.class, hint = "farthest") @Named("farthest")
@Singleton
public class FarthestConflictResolver implements ConflictResolver { public class FarthestConflictResolver implements ConflictResolver {
// ConflictResolver methods ----------------------------------------------- // ConflictResolver methods -----------------------------------------------

View File

@ -18,8 +18,10 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Resolves conflicting artifacts by always selecting the <em>nearest</em> declaration. Nearest is defined as the * Resolves conflicting artifacts by always selecting the <em>nearest</em> declaration. Nearest is defined as the
@ -29,7 +31,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a> * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
* @since 3.0 * @since 3.0
*/ */
@Component(role = ConflictResolver.class, hint = "nearest") @Named("nearest")
@Singleton
public class NearestConflictResolver implements ConflictResolver { public class NearestConflictResolver implements ConflictResolver {
// ConflictResolver methods ----------------------------------------------- // ConflictResolver methods -----------------------------------------------

View File

@ -18,10 +18,12 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Resolves conflicting artifacts by always selecting the <em>newest</em> declaration. Newest is defined as the * Resolves conflicting artifacts by always selecting the <em>newest</em> declaration. Newest is defined as the
@ -31,7 +33,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @see ArtifactVersion#compareTo * @see ArtifactVersion#compareTo
* @since 3.0 * @since 3.0
*/ */
@Component(role = ConflictResolver.class, hint = "newest") @Named("newest")
@Singleton
public class NewestConflictResolver implements ConflictResolver { public class NewestConflictResolver implements ConflictResolver {
// ConflictResolver methods ----------------------------------------------- // ConflictResolver methods -----------------------------------------------

View File

@ -18,10 +18,12 @@
*/ */
package org.apache.maven.repository.legacy.resolver.conflict; package org.apache.maven.repository.legacy.resolver.conflict;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.resolver.ResolutionNode; import org.apache.maven.artifact.resolver.ResolutionNode;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Resolves conflicting artifacts by always selecting the <em>oldest</em> declaration. Oldest is defined as the * Resolves conflicting artifacts by always selecting the <em>oldest</em> declaration. Oldest is defined as the
@ -31,7 +33,8 @@ import org.codehaus.plexus.component.annotations.Component;
* @see ArtifactVersion#compareTo * @see ArtifactVersion#compareTo
* @since 3.0 * @since 3.0
*/ */
@Component(role = ConflictResolver.class, hint = "oldest") @Named("oldest")
@Singleton
public class OldestConflictResolver implements ConflictResolver { public class OldestConflictResolver implements ConflictResolver {
// ConflictResolver methods ----------------------------------------------- // ConflictResolver methods -----------------------------------------------

View File

@ -18,6 +18,8 @@
*/ */
package org.apache.maven.repository.legacy.resolver.transform; package org.apache.maven.repository.legacy.resolver.transform;
import javax.inject.Inject;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
@ -34,7 +36,6 @@ import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.repository.legacy.WagonManager; import org.apache.maven.repository.legacy.WagonManager;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
/** /**
@ -44,10 +45,10 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
* TODO try and refactor to remove abstract methods - not particular happy about current design * TODO try and refactor to remove abstract methods - not particular happy about current design
*/ */
public abstract class AbstractVersionTransformation extends AbstractLogEnabled implements ArtifactTransformation { public abstract class AbstractVersionTransformation extends AbstractLogEnabled implements ArtifactTransformation {
@Requirement @Inject
protected RepositoryMetadataManager repositoryMetadataManager; protected RepositoryMetadataManager repositoryMetadataManager;
@Requirement @Inject
protected WagonManager wagonManager; protected WagonManager wagonManager;
public void transformForResolve( public void transformForResolve(

View File

@ -18,7 +18,15 @@
*/ */
package org.apache.maven.repository.legacy.resolver.transform; package org.apache.maven.repository.legacy.resolver.transform;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeploymentException; import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
@ -27,19 +35,24 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
* @author Jason van Zyl * @author Jason van Zyl
*/ */
@Component(role = ArtifactTransformationManager.class) @Named
@Singleton
public class DefaultArtifactTransformationManager implements ArtifactTransformationManager { public class DefaultArtifactTransformationManager implements ArtifactTransformationManager {
@Requirement(
role = ArtifactTransformation.class,
hints = {"release", "latest", "snapshot"})
private List<ArtifactTransformation> artifactTransformations; private List<ArtifactTransformation> artifactTransformations;
@Inject
public DefaultArtifactTransformationManager(Map<String, ArtifactTransformation> artifactTransformations) {
this.artifactTransformations = Stream.of("release", "latest", "snapshot")
.map(artifactTransformations::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
public void transformForResolve(Artifact artifact, RepositoryRequest request) public void transformForResolve(Artifact artifact, RepositoryRequest request)
throws ArtifactResolutionException, ArtifactNotFoundException { throws ArtifactResolutionException, ArtifactNotFoundException {
for (ArtifactTransformation transform : artifactTransformations) { for (ArtifactTransformation transform : artifactTransformations) {

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.repository.legacy.resolver.transform; package org.apache.maven.repository.legacy.resolver.transform;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.RepositoryRequest; import org.apache.maven.artifact.repository.RepositoryRequest;
@ -25,12 +28,12 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutio
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Describes a version transformation during artifact resolution - "latest" type * Describes a version transformation during artifact resolution - "latest" type
*/ */
@Component(role = ArtifactTransformation.class, hint = "latest") @Named("latest")
@Singleton
public class LatestArtifactTransformation extends AbstractVersionTransformation { public class LatestArtifactTransformation extends AbstractVersionTransformation {
public void transformForResolve(Artifact artifact, RepositoryRequest request) public void transformForResolve(Artifact artifact, RepositoryRequest request)

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.repository.legacy.resolver.transform; package org.apache.maven.repository.legacy.resolver.transform;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
@ -27,14 +30,14 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutio
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component;
/** /**
* Change the version <code>RELEASE</code> to the appropriate release version from the remote repository. * Change the version <code>RELEASE</code> to the appropriate release version from the remote repository.
* *
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/ */
@Component(role = ArtifactTransformation.class, hint = "release") @Named("release")
@Singleton
public class ReleaseArtifactTransformation extends AbstractVersionTransformation { public class ReleaseArtifactTransformation extends AbstractVersionTransformation {
public void transformForResolve(Artifact artifact, RepositoryRequest request) public void transformForResolve(Artifact artifact, RepositoryRequest request)

View File

@ -18,6 +18,9 @@
*/ */
package org.apache.maven.repository.legacy.resolver.transform; package org.apache.maven.repository.legacy.resolver.transform;
import javax.inject.Named;
import javax.inject.Singleton;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -35,14 +38,14 @@ import org.apache.maven.artifact.repository.metadata.Snapshot;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning; import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
/** /**
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a> * @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a>
*/ */
@Component(role = ArtifactTransformation.class, hint = "snapshot") @Named("snapshot")
@Singleton
public class SnapshotTransformation extends AbstractVersionTransformation { public class SnapshotTransformation extends AbstractVersionTransformation {
private static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss"; private static final String DEFAULT_SNAPSHOT_TIMESTAMP_FORMAT = "yyyyMMdd.HHmmss";

View File

@ -18,13 +18,15 @@
*/ */
package org.apache.maven.repository.metadata; package org.apache.maven.repository.metadata;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.artifact.ArtifactScopeEnum;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
* default implementation of the metadata classpath transformer * default implementation of the metadata classpath transformer
@ -32,9 +34,10 @@ import org.codehaus.plexus.component.annotations.Requirement;
* @author <a href="oleg@codehaus.org">Oleg Gusakov</a> * @author <a href="oleg@codehaus.org">Oleg Gusakov</a>
* *
*/ */
@Component(role = ClasspathTransformation.class) @Named
@Singleton
public class DefaultClasspathTransformation implements ClasspathTransformation { public class DefaultClasspathTransformation implements ClasspathTransformation {
@Requirement @Inject
GraphConflictResolver conflictResolver; GraphConflictResolver conflictResolver;
// ---------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------

View File

@ -18,16 +18,19 @@
*/ */
package org.apache.maven.repository.metadata; package org.apache.maven.repository.metadata;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Configuration; import org.codehaus.plexus.component.annotations.Configuration;
/** /**
* @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a> * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
* *
*/ */
@Component(role = GraphConflictResolutionPolicy.class) @Named
@Singleton
public class DefaultGraphConflictResolutionPolicy implements GraphConflictResolutionPolicy { public class DefaultGraphConflictResolutionPolicy implements GraphConflictResolutionPolicy {
/** /**
* artifact, closer to the entry point, is selected * artifact, closer to the entry point, is selected

View File

@ -18,25 +18,28 @@
*/ */
package org.apache.maven.repository.metadata; package org.apache.maven.repository.metadata;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import org.apache.maven.artifact.ArtifactScopeEnum; import org.apache.maven.artifact.ArtifactScopeEnum;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/** /**
* Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus * Default conflict resolver.Implements closer newer first policy by default, but could be configured via plexus
* *
* @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a> * @author <a href="mailto:oleg@codehaus.org">Oleg Gusakov</a>
*/ */
@Component(role = GraphConflictResolver.class) @Named
@Singleton
public class DefaultGraphConflictResolver implements GraphConflictResolver { public class DefaultGraphConflictResolver implements GraphConflictResolver {
/** /**
* artifact, closer to the entry point, is selected * artifact, closer to the entry point, is selected
*/ */
@Requirement(role = GraphConflictResolutionPolicy.class) @Inject
protected GraphConflictResolutionPolicy policy; protected GraphConflictResolutionPolicy policy;
// ------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------

View File

@ -27,7 +27,9 @@ import org.apache.maven.toolchain.model.PersistedToolchains;
* <strong>Note:</strong> This is an internal component whose interface can change without prior notice. * <strong>Note:</strong> This is an internal component whose interface can change without prior notice.
* *
* @author Benjamin Bentmann * @author Benjamin Bentmann
* @deprecated use {@link org.apache.maven.toolchain.building.ToolchainsBuilder} instead
*/ */
@Deprecated
public interface ToolchainsBuilder { public interface ToolchainsBuilder {
/** /**

View File

@ -0,0 +1,286 @@
/*
* 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;
import javax.inject.Inject;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.DefaultMavenExecutionResult;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.internal.impl.DefaultSession;
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
@PlexusTest
public abstract class AbstractCoreMavenComponentTestCase {
@Inject
protected PlexusContainer container;
@Inject
protected RepositorySystem repositorySystem;
@Inject
protected org.apache.maven.project.ProjectBuilder projectBuilder;
protected abstract String getProjectsDirectory();
protected PlexusContainer getContainer() {
return container;
}
protected File getProject(String name) throws Exception {
File source = new File(new File(getBasedir(), getProjectsDirectory()), name);
File target = new File(new File(getBasedir(), "target"), name);
FileUtils.copyDirectoryStructureIfModified(source, target);
return new File(target, "pom.xml");
}
protected MavenExecutionRequest createMavenExecutionRequest(File pom) throws Exception {
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setPom(pom)
.setProjectPresent(true)
.setShowErrors(true)
.setPluginGroups(Arrays.asList("org.apache.maven.plugins"))
.setLocalRepository(getLocalRepository())
.setRemoteRepositories(getRemoteRepositories())
.setPluginArtifactRepositories(getPluginArtifactRepositories())
.setGoals(Arrays.asList("package"));
if (pom != null) {
request.setMultiModuleProjectDirectory(pom.getParentFile());
}
return request;
}
// layer the creation of a project builder configuration with a request, but this will need to be
// a Maven subclass because we don't want to couple maven to the project builder which we need to
// separate.
protected MavenSession createMavenSession(File pom) throws Exception {
return createMavenSession(pom, new Properties());
}
protected MavenSession createMavenSession(File pom, Properties executionProperties) throws Exception {
return createMavenSession(pom, executionProperties, false);
}
protected MavenSession createMavenSession(File pom, Properties executionProperties, boolean includeModules)
throws Exception {
MavenExecutionRequest request = createMavenExecutionRequest(pom);
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest()
.setLocalRepository(request.getLocalRepository())
.setRemoteRepositories(request.getRemoteRepositories())
.setPluginArtifactRepositories(request.getPluginArtifactRepositories())
.setSystemProperties(executionProperties)
.setUserProperties(new Properties());
List<MavenProject> projects = new ArrayList<>();
if (pom != null) {
MavenProject project = projectBuilder.build(pom, configuration).getProject();
projects.add(project);
if (includeModules) {
for (String module : project.getModules()) {
File modulePom = new File(pom.getParentFile(), module);
if (modulePom.isDirectory()) {
modulePom = new File(modulePom, "pom.xml");
}
projects.add(projectBuilder.build(modulePom, configuration).getProject());
}
}
} else {
MavenProject project = createStubMavenProject();
project.setRemoteArtifactRepositories(request.getRemoteRepositories());
project.setPluginArtifactRepositories(request.getPluginArtifactRepositories());
projects.add(project);
}
initRepoSession(configuration);
MavenSession session = new MavenSession(
getContainer(), configuration.getRepositorySession(), request, new DefaultMavenExecutionResult());
session.setProjects(projects);
session.setAllProjects(session.getProjects());
session.setSession(new DefaultSession(session, new DefaultRepositorySystem(), null, null, null, null));
return session;
}
protected void initRepoSession(ProjectBuildingRequest request) throws Exception {
File localRepoDir = new File(request.getLocalRepository().getBasedir());
LocalRepository localRepo = new LocalRepository(localRepoDir);
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory().newInstance(session, localRepo));
request.setRepositorySession(session);
}
protected MavenProject createStubMavenProject() {
Model model = new Model();
model.setGroupId("org.apache.maven.test");
model.setArtifactId("maven-test");
model.setVersion("1.0");
return new MavenProject(model);
}
protected List<ArtifactRepository> getRemoteRepositories() throws InvalidRepositoryException {
File repoDir = new File(getBasedir(), "src/test/remote-repo").getAbsoluteFile();
RepositoryPolicy policy = new RepositoryPolicy();
policy.setEnabled(true);
policy.setChecksumPolicy("ignore");
policy.setUpdatePolicy("always");
Repository repository = new Repository();
repository.setId(MavenRepositorySystem.DEFAULT_REMOTE_REPO_ID);
repository.setUrl("file://" + repoDir.toURI().getPath());
repository.setReleases(policy);
repository.setSnapshots(policy);
return Arrays.asList(repositorySystem.buildArtifactRepository(repository));
}
protected List<ArtifactRepository> getPluginArtifactRepositories() throws InvalidRepositoryException {
return getRemoteRepositories();
}
protected ArtifactRepository getLocalRepository() throws InvalidRepositoryException {
File repoDir = new File(getBasedir(), "target/local-repo").getAbsoluteFile();
return repositorySystem.createLocalRepository(repoDir);
}
protected class ProjectBuilder {
private MavenProject project;
public ProjectBuilder(MavenProject project) {
this.project = project;
}
public ProjectBuilder(String groupId, String artifactId, String version) {
Model model = new Model();
model.setModelVersion("4.0.0");
model.setGroupId(groupId);
model.setArtifactId(artifactId);
model.setVersion(version);
model.setBuild(new Build());
project = new MavenProject(model);
}
public ProjectBuilder setGroupId(String groupId) {
project.setGroupId(groupId);
return this;
}
public ProjectBuilder setArtifactId(String artifactId) {
project.setArtifactId(artifactId);
return this;
}
public ProjectBuilder setVersion(String version) {
project.setVersion(version);
return this;
}
// Dependencies
//
public ProjectBuilder addDependency(String groupId, String artifactId, String version, String scope) {
return addDependency(groupId, artifactId, version, scope, (Exclusion) null);
}
public ProjectBuilder addDependency(
String groupId, String artifactId, String version, String scope, Exclusion exclusion) {
return addDependency(groupId, artifactId, version, scope, null, exclusion);
}
public ProjectBuilder addDependency(
String groupId, String artifactId, String version, String scope, String systemPath) {
return addDependency(groupId, artifactId, version, scope, systemPath, null);
}
public ProjectBuilder addDependency(
String groupId,
String artifactId,
String version,
String scope,
String systemPath,
Exclusion exclusion) {
Dependency d = new Dependency();
d.setGroupId(groupId);
d.setArtifactId(artifactId);
d.setVersion(version);
d.setScope(scope);
if (systemPath != null && scope.equals(Artifact.SCOPE_SYSTEM)) {
d.setSystemPath(systemPath);
}
if (exclusion != null) {
d.addExclusion(exclusion);
}
project.getDependencies().add(d);
return this;
}
// Plugins
//
public ProjectBuilder addPlugin(Plugin plugin) {
project.getBuildPlugins().add(plugin);
return this;
}
public MavenProject get() {
return project;
}
}
}

View File

@ -0,0 +1,79 @@
/*
* 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.artifact.metadata;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest;
import org.eclipse.sisu.Priority;
@Singleton
@Priority(10)
@Named
public class SwitchableMetadataSource implements ArtifactMetadataSource {
private ArtifactMetadataSource delegate;
@Inject
public SwitchableMetadataSource(@Named("test") ArtifactMetadataSource delegate) {
this.delegate = delegate;
}
public void setDelegate(ArtifactMetadataSource delegate) {
this.delegate = delegate;
}
@Override
public ResolutionGroup retrieve(MetadataResolutionRequest request) throws ArtifactMetadataRetrievalException {
return delegate.retrieve(request);
}
@Override
public ResolutionGroup retrieve(
Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
throws ArtifactMetadataRetrievalException {
return delegate.retrieve(artifact, localRepository, remoteRepositories);
}
@Override
public List<ArtifactVersion> retrieveAvailableVersions(MetadataResolutionRequest request)
throws ArtifactMetadataRetrievalException {
return delegate.retrieveAvailableVersions(request);
}
@Override
public List<ArtifactVersion> retrieveAvailableVersions(
Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories)
throws ArtifactMetadataRetrievalException {
return delegate.retrieveAvailableVersions(artifact, localRepository, remoteRepositories);
}
@Override
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository)
throws ArtifactMetadataRetrievalException {
return delegate.retrieveAvailableVersionsFromDeploymentRepository(artifact, localRepository, remoteRepository);
}
}

View File

@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.SwitchableMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
@ -36,12 +37,15 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.project.artifact.DefaultMetadataSource;
import org.apache.maven.repository.legacy.LegacyRepositorySystem; import org.apache.maven.repository.legacy.LegacyRepositorySystem;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.testing.PlexusTest;
import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.LocalRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.codehaus.plexus.testing.PlexusExtension.getBasedir; import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
@ -57,7 +61,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@PlexusTest @PlexusTest
class LegacyRepositorySystemTest { class LegacyRepositorySystemTest {
@Inject @Inject
private RepositorySystem repositorySystem; private LegacyRepositorySystem repositorySystem;
@Inject @Inject
private ResolutionErrorHandler resolutionErrorHandler; private ResolutionErrorHandler resolutionErrorHandler;
@ -184,4 +188,15 @@ class LegacyRepositorySystemTest {
assertEquals(localRepoDir.getPath(), basedir); assertEquals(localRepoDir.getPath(), basedir);
} }
@Inject
DefaultMetadataSource defaultMetadataSource;
@Inject
SwitchableMetadataSource switchableMetadataSource;
@BeforeEach
void setup() throws CycleDetectedInComponentGraphException {
switchableMetadataSource.setDelegate(defaultMetadataSource);
}
} }

View File

@ -16,8 +16,9 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.maven.internal.impl; package org.apache.maven.repository;
import javax.annotation.Priority;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -44,15 +45,12 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.io.ModelReader; import org.apache.maven.model.io.ModelReader;
import org.apache.maven.project.artifact.ArtifactWithDependencies; import org.apache.maven.project.artifact.ArtifactWithDependencies;
import org.apache.maven.repository.ArtifactDoesNotExistException;
import org.apache.maven.repository.ArtifactTransferFailedException;
import org.apache.maven.repository.ArtifactTransferListener;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server; import org.apache.maven.settings.Server;
@ -63,12 +61,17 @@ import org.eclipse.aether.RepositorySystemSession;
*/ */
@Named @Named
@Singleton @Singleton
@Priority(10)
public class TestRepositorySystem implements RepositorySystem { public class TestRepositorySystem implements RepositorySystem {
private final ModelReader modelReader; private final ModelReader modelReader;
private final ArtifactFactory artifactFactory; private final ArtifactFactory artifactFactory;
public TestRepositorySystem() {
this(null, null);
}
@Inject @Inject
public TestRepositorySystem(ModelReader modelReader, ArtifactFactory artifactFactory) { public TestRepositorySystem(ModelReader modelReader, ArtifactFactory artifactFactory) {
this.modelReader = modelReader; this.modelReader = modelReader;
@ -144,7 +147,7 @@ public class TestRepositorySystem implements RepositorySystem {
public ArtifactRepository createLocalRepository(File localRepository) throws InvalidRepositoryException { public ArtifactRepository createLocalRepository(File localRepository) throws InvalidRepositoryException {
return new MavenArtifactRepository( return new MavenArtifactRepository(
DEFAULT_LOCAL_REPO_ID, MavenRepositorySystem.DEFAULT_LOCAL_REPO_ID,
"file://" + localRepository.toURI().getPath(), "file://" + localRepository.toURI().getPath(),
new DefaultRepositoryLayout(), new DefaultRepositoryLayout(),
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy(),

View File

@ -25,7 +25,6 @@ import java.util.Arrays;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.artifact.repository.Authentication;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.settings.Server; import org.apache.maven.settings.Server;
import org.codehaus.plexus.testing.PlexusTest; import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -41,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
@PlexusTest @PlexusTest
class LegacyRepositorySystemTest { class LegacyRepositorySystemTest {
@Inject @Inject
private RepositorySystem repositorySystem; private LegacyRepositorySystem repositorySystem;
@Test @Test
void testThatLocalRepositoryWithSpacesIsProperlyHandled() throws Exception { void testThatLocalRepositoryWithSpacesIsProperlyHandled() throws Exception {

Some files were not shown because too many files have changed in this diff Show More