From 0e34b35947d0063dff9e579618e0ea3e38315f6f Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 2 Jan 2021 23:19:24 +0100 Subject: [PATCH] [MNG-6909] Convert to JSR330 in tests - maven-compat --- .../AbstractArtifactComponentTestCase.java | 15 +++++++-- .../deployer/ArtifactDeployerTest.java | 11 ++----- .../SimpleArtifactMetadataSource.java | 13 ++++---- .../factory/DefaultArtifactFactoryTest.java | 24 ++++++++++++-- .../installer/ArtifactInstallerTest.java | 11 ++----- .../artifact/metadata/TestMetadataSource.java | 11 ++++--- .../resolver/ArtifactResolverTest.java | 13 +++----- .../resolver/DefaultArtifactResolverTest.java | 9 +++--- .../transform/TransformationManagerTest.java | 24 +++++++++++--- .../manager/DefaultProfileManagerTest.java | 14 ++++++--- .../project/AbstractMavenProjectTestCase.java | 18 +++++++++-- .../project/ClasspathArtifactResolver.java | 7 +++-- .../maven/project/ProjectClasspathTest.java | 19 +++++++++--- .../maven/project/TestArtifactResolver.java | 16 +++++++--- .../project/TestMavenRepositorySystem.java | 14 ++++++--- .../maven/project/TestProjectBuilder.java | 7 +++-- .../repository/DefaultMirrorSelectorTest.java | 11 +++---- .../LegacyRepositorySystemTest.java | 23 +++++++------- .../maven/repository/MirrorProcessorTest.java | 28 +++++++++++------ .../legacy/DefaultWagonManagerTest.java | 31 +++++++++---------- .../legacy/LegacyRepositorySystemTest.java | 19 ++++++------ .../repository/legacy/PerLookupWagon.java | 6 ++-- .../maven/repository/legacy/StringWagon.java | 8 +++-- .../maven/repository/legacy/WagonA.java | 9 +++--- .../maven/repository/legacy/WagonB.java | 9 +++--- .../maven/repository/legacy/WagonC.java | 9 +++--- .../AbstractConflictResolverTest.java | 16 ++++++---- .../metadata/TestMetadataSource.java | 10 +++--- 28 files changed, 250 insertions(+), 155 deletions(-) diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java index ab59ae6812..3c0ce1371b 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/AbstractArtifactComponentTestCase.java @@ -29,6 +29,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; @@ -54,6 +55,7 @@ import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector; import org.eclipse.aether.util.graph.traverser.FatArtifactTraverser; import org.eclipse.aether.util.repository.SimpleArtifactDescriptorPolicy; +import javax.inject.Inject; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -62,6 +64,7 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -70,10 +73,15 @@ import java.util.List; public abstract class AbstractArtifactComponentTestCase extends PlexusTestCase { + @Inject protected ArtifactFactory artifactFactory; + @Inject protected ArtifactRepositoryFactory artifactRepositoryFactory; + @Inject + LegacySupport legacySupport; + @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { @@ -87,14 +95,15 @@ public abstract class AbstractArtifactComponentTestCase throws Exception { super.setUp(); - artifactFactory = lookup( ArtifactFactory.class ); - artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); + + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); RepositorySystemSession repoSession = initRepoSession(); MavenSession session = new MavenSession( getContainer(), repoSession, new DefaultMavenExecutionRequest(), new DefaultMavenExecutionResult() ); - LegacySupport legacySupport = lookup( LegacySupport.class ); legacySupport.setSession( session ); } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java index f929f4801b..30b1ab3396 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/ArtifactDeployerTest.java @@ -26,22 +26,17 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.util.FileUtils; +import javax.inject.Inject; + /** * @author Jason van Zyl */ public class ArtifactDeployerTest extends AbstractArtifactComponentTestCase { + @Inject private ArtifactDeployer artifactDeployer; - protected void setUp() - throws Exception - { - super.setUp(); - - artifactDeployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE ); - } - protected String component() { return "deployer"; diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java index f6bebcbaeb..8f6caa8265 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/deployer/SimpleArtifactMetadataSource.java @@ -31,34 +31,35 @@ import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.ResolutionGroup; +import javax.inject.Named; +import javax.inject.Singleton; + /** @author Jason van Zyl */ +@Named( "classpath" ) +@Singleton public class SimpleArtifactMetadataSource implements ArtifactMetadataSource { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot retrieve metadata in this test case" ); } public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException { - return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); + return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); } public List retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException { - return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); + return Collections.singletonList( new DefaultArtifactVersion( "10.1.3" ) ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java index a90c33b66b..cee9f5a11d 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/factory/DefaultArtifactFactoryTest.java @@ -21,14 +21,25 @@ package org.apache.maven.artifact.factory; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import org.eclipse.aether.RepositorySystemSession; + +import javax.inject.Inject; +import java.util.Collections; public class DefaultArtifactFactoryTest extends PlexusTestCase { + @Inject + ArtifactFactory factory; + @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { @@ -37,10 +48,19 @@ public class DefaultArtifactFactoryTest containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } - public void testPropagationOfSystemScopeRegardlessOfInheritedScope() throws Exception + @Override + protected void setUp() + throws Exception { - ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + super.setUp(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); + } + + public void testPropagationOfSystemScopeRegardlessOfInheritedScope() + { Artifact artifact = factory.createDependencyArtifact( "test-grp", "test-artifact", VersionRange.createFromVersion("1.0"), "type", null, "system", "provided" ); Artifact artifact2 = factory.createDependencyArtifact( "test-grp", "test-artifact-2", VersionRange.createFromVersion("1.0"), "type", null, "system", "test" ); Artifact artifact3 = factory.createDependencyArtifact( "test-grp", "test-artifact-3", VersionRange.createFromVersion("1.0"), "type", null, "system", "runtime" ); diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java index 21bfb2b70b..df519b3b25 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/installer/ArtifactInstallerTest.java @@ -24,22 +24,17 @@ import java.io.File; import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; +import javax.inject.Inject; + /** * @author Jason van Zyl */ public class ArtifactInstallerTest extends AbstractArtifactComponentTestCase { + @Inject private ArtifactInstaller artifactInstaller; - protected void setUp() - throws Exception - { - super.setUp(); - - artifactInstaller = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE ); - } - protected String component() { return "installer"; diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java index e3e385e29b..f1973f9e60 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/metadata/TestMetadataSource.java @@ -28,14 +28,17 @@ import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -@Component(role = ArtifactMetadataSource.class, hint="test") +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +@Named( "test" ) +@Singleton public class TestMetadataSource implements ArtifactMetadataSource { - @Requirement + @Inject private ArtifactFactory factory; public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java index 72a2017f61..00c1344da5 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java @@ -36,6 +36,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; +import javax.inject.Inject; + // It would be cool if there was a hook that i could use to setup a test environment. // I want to setup a local/remote repositories for testing but i don't want to have // to change them when i change the layout of the repositories. So i want to generate @@ -48,7 +50,8 @@ import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; public class ArtifactResolverTest extends AbstractArtifactComponentTestCase { - private DefaultArtifactResolver artifactResolver; + @Inject + private ArtifactResolver artifactResolver; private Artifact projectArtifact; @@ -58,8 +61,6 @@ public class ArtifactResolverTest { super.setUp(); - artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); - projectArtifact = createLocalArtifact( "project", "3.0" ); } @@ -67,7 +68,6 @@ public class ArtifactResolverTest protected void tearDown() throws Exception { - artifactFactory = null; projectArtifact = null; super.tearDown(); } @@ -193,7 +193,6 @@ public class ArtifactResolverTest { public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException { Set dependencies = new HashSet<>(); @@ -203,7 +202,6 @@ public class ArtifactResolverTest public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) - throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } @@ -212,19 +210,16 @@ public class ArtifactResolverTest Artifact artifact, ArtifactRepository localRepository, ArtifactRepository remoteRepository ) - throws ArtifactMetadataRetrievalException { throw new UnsupportedOperationException( "Cannot get available versions in this test case" ); } public ResolutionGroup retrieve( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException { return retrieve( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } public List retrieveAvailableVersions( MetadataResolutionRequest request ) - throws ArtifactMetadataRetrievalException { return retrieveAvailableVersions( request.getArtifact(), request.getLocalRepository(), request.getRemoteRepositories() ); } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java index 914d9d1c3f..9e221eeef7 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactResolverTest.java @@ -25,10 +25,13 @@ import org.apache.maven.artifact.AbstractArtifactComponentTestCase; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.DefaultArtifactResolver.DaemonThreadCreator; +import javax.inject.Inject; + public class DefaultArtifactResolverTest extends AbstractArtifactComponentTestCase { - private DefaultArtifactResolver artifactResolver; + @Inject + private ArtifactResolver artifactResolver; private Artifact projectArtifact; @@ -37,9 +40,6 @@ public class DefaultArtifactResolverTest throws Exception { super.setUp(); - - artifactResolver = (DefaultArtifactResolver) lookup( ArtifactResolver.class ); - projectArtifact = createLocalArtifact( "project", "3.0" ); } @@ -47,7 +47,6 @@ public class DefaultArtifactResolverTest protected void tearDown() throws Exception { - artifactFactory = null; projectArtifact = null; super.tearDown(); } diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java index 45b4c00ecd..ff0d3bbfa1 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/transform/TransformationManagerTest.java @@ -15,20 +15,28 @@ package org.apache.maven.artifact.transform; * the License. */ +import java.util.Collections; import java.util.List; +import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager; import org.apache.maven.repository.legacy.resolver.transform.LatestArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.ReleaseArtifactTransformation; import org.apache.maven.repository.legacy.resolver.transform.SnapshotTransformation; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import javax.inject.Inject; + /** @author Jason van Zyl */ public class TransformationManagerTest extends PlexusTestCase { + @Inject + ArtifactTransformationManager tm; + @Override protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { @@ -37,12 +45,20 @@ public class TransformationManagerTest containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } - public void testTransformationManager() - throws Exception + @Override + protected void setUp() + throws Exception { - ArtifactTransformationManager tm = lookup( ArtifactTransformationManager.class ); + super.setUp(); - List tms = tm.getArtifactTransformations(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); + } + + public void testTransformationManager() + { + List tms = tm.getArtifactTransformations(); assertEquals( 3, tms.size() ); diff --git a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java index 7431808634..6b8caabf0f 100644 --- a/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/profiles/manager/DefaultProfileManagerTest.java @@ -19,28 +19,34 @@ package org.apache.maven.profiles.manager; * under the License. */ +import java.util.Collections; import java.util.List; import java.util.Properties; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationProperty; import org.apache.maven.model.Profile; import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.ProfileManager; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import org.eclipse.aether.RepositorySystemSession; public class DefaultProfileManagerTest extends PlexusTestCase { @Override - protected void customizeContainerConfiguration( ContainerConfiguration configuration ) + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { - super.customizeContainerConfiguration( configuration ); - configuration.setAutoWiring( true ); - configuration.setClassPathScanning( PlexusConstants.SCANNING_ON ); + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } public void testShouldActivateDefaultProfile() diff --git a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java index 4caeb6f69e..d05aa8f59a 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java +++ b/maven-compat/src/test/java/org/apache/maven/project/AbstractMavenProjectTestCase.java @@ -21,17 +21,25 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.Arrays; +import java.util.Collections; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.building.ModelBuildingException; import org.apache.maven.model.building.ModelProblem; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystemSession; + +import javax.inject.Inject; /** * @author Jason van Zyl @@ -41,6 +49,7 @@ public abstract class AbstractMavenProjectTestCase { protected ProjectBuilder projectBuilder; + @Inject protected RepositorySystem repositorySystem; @Override @@ -51,11 +60,16 @@ public abstract class AbstractMavenProjectTestCase containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } + @Override protected void setUp() - throws Exception + throws Exception { super.setUp(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); + if ( getContainer().hasComponent( ProjectBuilder.class, "test" ) ) { projectBuilder = lookup( ProjectBuilder.class, "test" ); @@ -65,8 +79,6 @@ public abstract class AbstractMavenProjectTestCase // default over to the main project builder... projectBuilder = lookup( ProjectBuilder.class ); } - - repositorySystem = lookup( RepositorySystem.class ); } @Override diff --git a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java index 90df8cbecc..f4813593f8 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ClasspathArtifactResolver.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.codehaus.plexus.component.annotations.Component; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.Artifact; import org.eclipse.aether.impl.ArtifactResolver; @@ -34,10 +33,14 @@ import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.transfer.ArtifactNotFoundException; +import javax.inject.Named; +import javax.inject.Singleton; + /** * @author Benjamin Bentmann */ -@Component( role = ArtifactResolver.class, hint = "classpath" ) +@Named( "classpath" ) +@Singleton public class ClasspathArtifactResolver implements ArtifactResolver { diff --git a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java index 10825d2c82..96f1feaa94 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java +++ b/maven-compat/src/test/java/org/apache/maven/project/ProjectClasspathTest.java @@ -20,12 +20,18 @@ package org.apache.maven.project; */ import java.io.File; +import java.util.Collections; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; +import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.impl.ArtifactDescriptorReader; import org.eclipse.aether.impl.ArtifactResolver; @@ -42,16 +48,21 @@ public class ProjectClasspathTest containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } - public void setUp() - throws Exception + @Override + protected void setUp() + throws Exception { + super.setUp(); + + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); + ArtifactResolver resolver = lookup( ArtifactResolver.class, "classpath" ); DefaultArtifactDescriptorReader pomReader = (DefaultArtifactDescriptorReader)lookup(ArtifactDescriptorReader.class); pomReader.setArtifactResolver( resolver ); projectBuilder = lookup( ProjectBuilder.class, "classpath" ); - - repositorySystem = lookup( RepositorySystem.class ); } @Override diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java b/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java index 9f389d6dd9..94b30dbb98 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java +++ b/maven-compat/src/test/java/org/apache/maven/project/TestArtifactResolver.java @@ -16,15 +16,21 @@ package org.apache.maven.project; */ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.DefaultArtifactResolver; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -@Component(role=ArtifactResolver.class,hint="classpath") +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +@Named( "classpath" ) +@Singleton public class TestArtifactResolver extends DefaultArtifactResolver { - @Requirement(hint="classpath") private ArtifactMetadataSource source; + + @Inject + public TestArtifactResolver(final @Named( "classpath" ) ArtifactMetadataSource source) { + this.source = source; + } } diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java b/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java index 2818df0630..1f37676711 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java +++ b/maven-compat/src/test/java/org/apache/maven/project/TestMavenRepositorySystem.java @@ -15,16 +15,20 @@ package org.apache.maven.project; * the License. */ +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.legacy.LegacyRepositorySystem; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -@Component(role = RepositorySystem.class, hint = "classpath") +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import java.util.Map; + +@Named( "classpath" ) +@Singleton public class TestMavenRepositorySystem extends LegacyRepositorySystem { - @Requirement(hint="classpath") + @Inject private ArtifactResolver artifactResolver; } diff --git a/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java b/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java index bb6a20d1f9..18deb4332b 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java +++ b/maven-compat/src/test/java/org/apache/maven/project/TestProjectBuilder.java @@ -19,9 +19,12 @@ import java.io.File; import java.util.Collections; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.codehaus.plexus.component.annotations.Component; -@Component(role=ProjectBuilder.class,hint="classpath") +import javax.inject.Named; +import javax.inject.Singleton; + +@Named( "classpath" ) +@Singleton public class TestProjectBuilder extends DefaultProjectBuilder { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java index 4e8cdb0a8b..5735db0ec5 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/DefaultMirrorSelectorTest.java @@ -21,18 +21,17 @@ package org.apache.maven.repository; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; public class DefaultMirrorSelectorTest - extends PlexusTestCase { - + @Test public void testMirrorWithMirrorOfPatternContainingANegationIsNotSelected() { ArtifactRepository repository = new DefaultArtifactRepository( "snapshots.repo", "http://whatever", null ); String pattern = "external:*, !snapshots.repo"; - boolean matches = DefaultMirrorSelector.matchPattern( repository, pattern ); - System.out.println( matches ); - assertFalse( matches ); + assertFalse( DefaultMirrorSelector.matchPattern( repository, pattern ) ); } } diff --git a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java index 17dfcfcc7b..65dbd892a1 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/LegacyRepositorySystemTest.java @@ -17,6 +17,7 @@ package org.apache.maven.repository; import java.io.File; import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; @@ -31,15 +32,19 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.repository.legacy.LegacyRepositorySystem; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; +import javax.inject.Inject; + /** * Tests {@link LegacyRepositorySystem}. * @@ -48,8 +53,9 @@ import org.eclipse.aether.repository.LocalRepository; public class LegacyRepositorySystemTest extends PlexusTestCase { + @Inject private RepositorySystem repositorySystem; - + @Inject private ResolutionErrorHandler resolutionErrorHandler; @Override @@ -62,20 +68,13 @@ public class LegacyRepositorySystemTest @Override protected void setUp() - throws Exception + throws Exception { super.setUp(); - repositorySystem = lookup( RepositorySystem.class, "default" ); - resolutionErrorHandler = lookup( ResolutionErrorHandler.class ); - } - @Override - protected void tearDown() - throws Exception - { - repositorySystem = null; - resolutionErrorHandler = null; - super.tearDown(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); } protected List getRemoteRepositories() diff --git a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java index 57645750c8..8492f7bcad 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/MirrorProcessorTest.java @@ -20,35 +20,45 @@ package org.apache.maven.repository; */ import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.settings.Mirror; +import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import javax.inject.Inject; + public class MirrorProcessorTest extends PlexusTestCase { + @Inject private DefaultMirrorSelector mirrorSelector; + @Inject private ArtifactRepositoryFactory repositorySystem; - protected void setUp() - throws Exception + @Override + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) { - mirrorSelector = (DefaultMirrorSelector) lookup( MirrorSelector.class ); - repositorySystem = lookup( ArtifactRepositoryFactory.class ); + super.customizeContainerConfiguration( containerConfiguration ); + containerConfiguration.setAutoWiring( true ); + containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } @Override - protected void tearDown() - throws Exception + protected void setUp() + throws Exception { - mirrorSelector = null; - repositorySystem = null; + super.setUp(); - super.tearDown(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); } public void testExternalURL() diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java index 3424ac1ad6..9ddbe32ab9 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/DefaultWagonManagerTest.java @@ -22,6 +22,7 @@ package org.apache.maven.repository.legacy; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.maven.artifact.Artifact; @@ -44,22 +45,28 @@ import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.observers.AbstractTransferListener; import org.apache.maven.wagon.observers.Debug; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.FileUtils; +import javax.inject.Inject; + /** * @author Michal Maczka */ public class DefaultWagonManagerTest extends PlexusTestCase { - private DefaultWagonManager wagonManager; + @Inject + private WagonManager wagonManager; - private TransferListener transferListener = new Debug(); + private final TransferListener transferListener = new Debug(); + @Inject private ArtifactFactory artifactFactory; + @Inject private ArtifactRepositoryFactory artifactRepositoryFactory; @Override @@ -70,22 +77,15 @@ public class DefaultWagonManagerTest containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } + @Override protected void setUp() - throws Exception + throws Exception { super.setUp(); - wagonManager = (DefaultWagonManager) lookup( WagonManager.class ); - artifactFactory = lookup( ArtifactFactory.class ); - artifactRepositoryFactory = lookup( ArtifactRepositoryFactory.class ); - } - @Override - protected void tearDown() - throws Exception - { - wagonManager = null; - artifactFactory = null; - super.tearDown(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); } public void testUnnecessaryRepositoryLookup() @@ -164,8 +164,7 @@ public class DefaultWagonManagerTest } public void testGetRemoteJar() - throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException, - AuthorizationException + throws TransferFailedException, ResourceDoesNotExistException, UnsupportedProtocolException, IOException { Artifact artifact = createTestArtifact( "target/test-data/get-remote-jar", "jar" ); diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java index f34c05fb1f..d5f281fba5 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/LegacyRepositorySystemTest.java @@ -17,15 +17,19 @@ package org.apache.maven.repository.legacy; import java.io.File; import java.util.Arrays; +import java.util.Collections; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.Authentication; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Server; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import javax.inject.Inject; + /** * Tests {@link LegacyRepositorySystem}. * @@ -34,6 +38,7 @@ import org.codehaus.plexus.PlexusTestCase; public class LegacyRepositorySystemTest extends PlexusTestCase { + @Inject private RepositorySystem repositorySystem; @Override @@ -46,18 +51,13 @@ public class LegacyRepositorySystemTest @Override protected void setUp() - throws Exception + throws Exception { super.setUp(); - repositorySystem = lookup( RepositorySystem.class, "default" ); - } - @Override - protected void tearDown() - throws Exception - { - repositorySystem = null; - super.tearDown(); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); } public void testThatLocalRepositoryWithSpacesIsProperlyHandled() @@ -69,7 +69,6 @@ public class LegacyRepositorySystemTest } public void testAuthenticationHandling() - throws Exception { Server server = new Server(); server.setId( "repository" ); diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java index 051f3e4689..edf43aad90 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/PerLookupWagon.java @@ -20,12 +20,14 @@ package org.apache.maven.repository.legacy; */ import org.apache.maven.wagon.Wagon; -import org.codehaus.plexus.component.annotations.Component; + +import javax.inject.Named; +import javax.inject.Singleton; /** * Wagon with per-lookup instantiation strategy. */ -@Component( role = Wagon.class, hint = "perlookup", instantiationStrategy = "per-lookup" ) +@Named( "perlookup" ) public class PerLookupWagon extends WagonMock { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java index fde759ee73..00be1626dc 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/StringWagon.java @@ -31,13 +31,15 @@ import org.apache.maven.wagon.OutputData; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.StreamWagon; import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; import org.apache.maven.wagon.resource.Resource; -import org.codehaus.plexus.component.annotations.Component; -@Component(role=Wagon.class,hint="string") +import javax.inject.Named; +import javax.inject.Singleton; + +@Named( "string" ) +@Singleton public class StringWagon extends StreamWagon { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java index 601eefacc0..dbab864767 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonA.java @@ -1,8 +1,4 @@ package org.apache.maven.repository.legacy; - -import org.apache.maven.wagon.Wagon; -import org.codehaus.plexus.component.annotations.Component; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -21,6 +17,8 @@ import org.codehaus.plexus.component.annotations.Component; * specific language governing permissions and limitations * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; /** * Wagon for testing, for protocol a @@ -28,7 +26,8 @@ import org.codehaus.plexus.component.annotations.Component; * @author Carlos Sanchez * @author Jason van Zyl */ -@Component(role=Wagon.class,hint="a") +@Named( "a" ) +@Singleton public class WagonA extends WagonMock { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java index ecaef6423c..c08381113c 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonB.java @@ -1,8 +1,5 @@ package org.apache.maven.repository.legacy; -import org.apache.maven.wagon.Wagon; -import org.codehaus.plexus.component.annotations.Component; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,13 +19,17 @@ import org.codehaus.plexus.component.annotations.Component; * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + /** * Wagon for testing, for protocols b1 and b2 * * @author Carlos Sanchez * @author Jason van Zyl */ -@Component(role=Wagon.class,hint="b") +@Named( "b" ) +@Singleton public class WagonB extends WagonMock { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java index 29316ed5c2..29aa1de016 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/WagonC.java @@ -1,8 +1,5 @@ package org.apache.maven.repository.legacy; -import org.apache.maven.wagon.Wagon; -import org.codehaus.plexus.component.annotations.Component; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,13 +19,17 @@ import org.codehaus.plexus.component.annotations.Component; * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + /** * Wagon for testing, for protocol c * * @author Carlos Sanchez * @author Jason van Zyl */ -@Component(role=Wagon.class,hint="c") +@Named( "c" ) +@Singleton public class WagonC extends WagonMock { diff --git a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java index 1b4f4f4334..54ae26a1f6 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/legacy/resolver/conflict/AbstractConflictResolverTest.java @@ -27,9 +27,11 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.repository.legacy.resolver.conflict.ConflictResolver; import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusTestCase; +import javax.inject.Inject; import java.util.Collections; /** @@ -54,6 +56,7 @@ public abstract class AbstractConflictResolverTest private final String roleHint; + @Inject private ArtifactFactory artifactFactory; private ConflictResolver conflictResolver; @@ -76,14 +79,16 @@ public abstract class AbstractConflictResolverTest containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX ); } - /* - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception + @Override + protected void setUp() + throws Exception { super.setUp(); - artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + ((DefaultPlexusContainer)getContainer()) + .addPlexusInjector( Collections.emptyList(), + binder -> binder.requestInjection( this ) ); + conflictResolver = (ConflictResolver) lookup( ConflictResolver.ROLE, roleHint ); a1 = createArtifact( "a", "1.0" ); @@ -100,7 +105,6 @@ public abstract class AbstractConflictResolverTest a2 = null; b1 = null; - artifactFactory = null; conflictResolver = null; super.tearDown(); diff --git a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java index 2293e21b7e..fbb9035830 100644 --- a/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java +++ b/maven-compat/src/test/java/org/apache/maven/repository/metadata/TestMetadataSource.java @@ -27,18 +27,20 @@ import org.apache.maven.repository.legacy.metadata.ArtifactMetadataRetrievalExce import org.apache.maven.repository.legacy.metadata.ArtifactMetadataSource; import org.apache.maven.repository.legacy.metadata.MetadataResolutionRequest; import org.apache.maven.repository.legacy.metadata.ResolutionGroup; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; import java.util.HashSet; import java.util.List; import java.util.Set; -@Component(role = ArtifactMetadataSource.class) +@Named +@Singleton public class TestMetadataSource implements ArtifactMetadataSource { - @Requirement + @Inject private ArtifactFactory factory; public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )