You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/05/20 18:32:03 UTC
[maven] 01/02: [MNG-6909] Use CDI to inject beans
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MNG-6909
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 1bdc68267176a1c7604eb27e41847c96a9ee43fe
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed May 20 15:08:52 2020 +0200
[MNG-6909] Use CDI to inject beans
---
.../maven/artifact/AbstractArtifactComponentTestCase.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 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 dbd6e8f..ae8178b 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;
@@ -61,6 +63,7 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -69,10 +72,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 )
{
@@ -86,14 +94,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 );
}