Skip to content

Commit

Permalink
[MNG-7794][MNG-7809] Deprecate RepositorySystem and make maven-compat…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
gnodet committed Jun 15, 2023
1 parent 00d350e commit 967d8fc
Show file tree
Hide file tree
Showing 123 changed files with 966 additions and 576 deletions.
8 changes: 2 additions & 6 deletions maven-compat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ under the License.
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
Expand Down Expand Up @@ -127,8 +123,8 @@ under the License.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/**
* ArtifactFilterManager
*/
@Deprecated
public interface ArtifactFilterManager {
/**
* Returns a filter for core + extension artifacts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
/**
* @deprecated use {@code META-INF/maven/extension.xml} to define artifacts exported by Maven core extensions.
*/
@Deprecated
public interface ArtifactFilterManagerDelegate {

void addExcludes(Set<String> excludes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
@Named
@Singleton
@SuppressWarnings("deprecation")
@Deprecated
public class DefaultArtifactFilterManager implements ArtifactFilterManager {

// this is a live injected collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
* but should have been.
*
*/
@Deprecated
@Named
@Singleton
@Deprecated
public class DefaultProjectDependenciesResolver implements ProjectDependenciesResolver {

private final RepositorySystem repositorySystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.apache.maven.artifact.deployer;

import javax.inject.Inject;
import javax.inject.Named;

import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -33,8 +36,6 @@
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.plugin.LegacySupport;
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.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
Expand All @@ -49,13 +50,13 @@
/**
* DefaultArtifactDeployer
*/
@Component(role = ArtifactDeployer.class, instantiationStrategy = "per-lookup")
@Named
public class DefaultArtifactDeployer extends AbstractLogEnabled implements ArtifactDeployer {

@Requirement
@Inject
private RepositorySystem repoSystem;

@Requirement
@Inject
private LegacySupport legacySupport;

private Map<Object, MergeableMetadata> relatedMetadata = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.maven.artifact.installer;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;

import org.apache.maven.RepositoryUtils;
Expand All @@ -32,8 +36,6 @@
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.plugin.LegacySupport;
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.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
Expand All @@ -45,13 +47,14 @@
/**
* @author Jason van Zyl
*/
@Component(role = ArtifactInstaller.class)
@Named
@Singleton
public class DefaultArtifactInstaller extends AbstractLogEnabled implements ArtifactInstaller {

@Requirement
@Inject
private RepositorySystem repoSystem;

@Requirement
@Inject
private LegacySupport legacySupport;

/** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
package org.apache.maven.artifact.manager;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.util.List;

import org.apache.maven.artifact.Artifact;
Expand All @@ -37,31 +41,30 @@
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
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;

/**
* 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
implements WagonManager {

// 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;

@Requirement
@Inject
private LegacySupport legacySupport;

@Requirement
@Inject
private SettingsDecrypter settingsDecrypter;

@Requirement
@Inject
private MirrorSelector mirrorSelector;

@Requirement
@Inject
private ArtifactRepositoryFactory artifactRepositoryFactory;

public AuthenticationInfo getAuthenticationInfo(String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,36 @@
*/
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.List;

import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.repository.RepositorySystem;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.eclipse.aether.RepositorySystemSession;

/**
* @author jdcasey
*/
@Component(role = ArtifactRepositoryFactory.class)
@Named
@Singleton
public class DefaultArtifactRepositoryFactory implements ArtifactRepositoryFactory {

@Requirement
@Inject
private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory;

@Requirement
@Inject
private LegacySupport legacySupport;

@Requirement
private RepositorySystem repositorySystem;
@Inject
private PlexusContainer container;

public ArtifactRepositoryLayout getLayout(String layoutId) throws UnknownRepositoryLayoutException {
return factory.getLayout(layoutId);
Expand Down Expand Up @@ -92,6 +97,13 @@ private ArtifactRepository injectSession(ArtifactRepository repository, boolean
if (session != null && repository != null && !isLocalRepository(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) {
repositorySystem.injectMirror(session, repositories);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public class LegacyLocalRepositoryManager implements LocalRepositoryManager {

public static RepositorySystemSession overlay(
ArtifactRepository repository, RepositorySystemSession session, RepositorySystem system) {
return overlay(repository, session);
}

public static RepositorySystemSession overlay(ArtifactRepository repository, RepositorySystemSession session) {
if (repository == null || repository.getBasedir() == null) {
return session;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
*/
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.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.component.annotations.Component;

/**
* FlatRepositoryLayout
*/
@Component(role = ArtifactRepositoryLayout.class, hint = "flat")
@Named("flat")
@Singleton
public class FlatRepositoryLayout implements ArtifactRepositoryLayout {

private static final char ARTIFACT_SEPARATOR = '-';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
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.FileNotFoundException;
import java.io.IOException;
Expand All @@ -40,20 +44,19 @@
import org.apache.maven.repository.legacy.WagonManager;
import org.apache.maven.wagon.ResourceDoesNotExistException;
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.util.xml.pull.XmlPullParserException;

/**
* @author Jason van Zyl
*/
@Component(role = RepositoryMetadataManager.class)
@Named
@Singleton
public class DefaultRepositoryMetadataManager extends AbstractLogEnabled implements RepositoryMetadataManager {
@Requirement
@Inject
private WagonManager wagonManager;

@Requirement
@Inject
private UpdateCheckManager updateCheckManager;

public void resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/
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
* along with their metadata. No artifacts are downloaded.
*/
@Deprecated
@Component(role = ArtifactCollector.class)
@Named
@Singleton
public class DefaultArtifactCollector extends org.apache.maven.repository.legacy.resolver.DefaultLegacyArtifactCollector
implements ArtifactCollector {}

0 comments on commit 967d8fc

Please sign in to comment.