From aa3be9ef39af4daf3a0558f760e09ce55dbc8a6e Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Mon, 20 Mar 2023 09:00:36 +0100 Subject: [PATCH] Migrate off ancient Plexus components To JSR330, and drop use of archived plexus-component-metadata plugin and replace it with sisu-maven-index. --- devtools/maven/pom.xml | 21 +++++++------------ .../java/io/quarkus/maven/GoOfflineMojo.java | 1 - .../maven/QuarkusBootstrapProvider.java | 21 ++++++++++++------- .../components/BootstrapSessionListener.java | 17 ++++++++++----- .../components/MavenVersionEnforcer.java | 5 +++-- .../bootstrap/maven-plugin/pom.xml | 17 ++++++++------- .../maven/BootstrapWorkspaceProvider.java | 7 +++++-- .../extension-maven-plugin/pom.xml | 17 ++++++++------- .../maven/BootstrapWorkspaceProvider.java | 7 +++++-- 9 files changed, 67 insertions(+), 46 deletions(-) diff --git a/devtools/maven/pom.xml b/devtools/maven/pom.xml index 1ccf4e43baf75..2809b4e28706c 100644 --- a/devtools/maven/pom.xml +++ b/devtools/maven/pom.xml @@ -49,12 +49,8 @@ maven-plugin-api - jakarta.inject - jakarta.inject-api - - - jakarta.enterprise - jakarta.enterprise.cdi-api + javax.inject + javax.inject org.apache.maven @@ -172,16 +168,15 @@ - org.codehaus.plexus - plexus-component-metadata - 2.1.0 - - ${basedir}/target/filtered-resources/META-INF/plexus - + org.eclipse.sisu + sisu-maven-plugin + 0.3.5 + index-project - generate-metadata + main-index + test-index diff --git a/devtools/maven/src/main/java/io/quarkus/maven/GoOfflineMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/GoOfflineMojo.java index 76b6bda9e6fa7..e3251b8130ec4 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/GoOfflineMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/GoOfflineMojo.java @@ -31,7 +31,6 @@ import io.quarkus.bootstrap.util.IoUtils; import io.quarkus.bootstrap.workspace.ArtifactSources; import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.runtime.LaunchMode; /** * This goal downloads all the Maven artifact dependencies required to build, run, test and diff --git a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java index f645cbc37f0aa..acd1662778981 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java @@ -15,13 +15,15 @@ import java.util.Set; import java.util.concurrent.ExecutionException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.impl.RemoteRepositoryManager; @@ -45,21 +47,26 @@ import io.quarkus.runtime.LaunchMode; import io.smallrye.common.expression.Expression; -@Component(role = QuarkusBootstrapProvider.class, instantiationStrategy = "singleton") +@Singleton +@Named public class QuarkusBootstrapProvider implements Closeable { private static final String MANIFEST_SECTIONS_PROPERTY_PREFIX = "quarkus.package.manifest.manifest-sections"; private static final String MANIFEST_ATTRIBUTES_PROPERTY_PREFIX = "quarkus.package.manifest.attributes"; - @Requirement(role = RepositorySystem.class, optional = false) - protected RepositorySystem repoSystem; + private final RepositorySystem repoSystem; - @Requirement(role = RemoteRepositoryManager.class, optional = false) - protected RemoteRepositoryManager remoteRepoManager; + private final RemoteRepositoryManager remoteRepoManager; private final Cache appBootstrapProviders = CacheBuilder.newBuilder() .concurrencyLevel(4).softValues().initialCapacity(10).build(); + @Inject + public QuarkusBootstrapProvider(RepositorySystem repoSystem, RemoteRepositoryManager remoteRepoManager) { + this.repoSystem = repoSystem; + this.remoteRepoManager = remoteRepoManager; + } + static ArtifactKey getProjectId(MavenProject project) { return ArtifactKey.ga(project.getGroupId(), project.getArtifactId()); } diff --git a/devtools/maven/src/main/java/io/quarkus/maven/components/BootstrapSessionListener.java b/devtools/maven/src/main/java/io/quarkus/maven/components/BootstrapSessionListener.java index aaf8670c8667f..31b338f88497f 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/components/BootstrapSessionListener.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/components/BootstrapSessionListener.java @@ -2,22 +2,29 @@ import java.io.IOException; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.AbstractMavenLifecycleParticipant; import org.apache.maven.MavenExecutionException; import org.apache.maven.execution.MavenSession; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import io.quarkus.maven.QuarkusBootstrapProvider; -@Component(role = AbstractMavenLifecycleParticipant.class, hint = "quarkus-bootstrap") +@Singleton +@Named("quarkus-bootstrap") public class BootstrapSessionListener extends AbstractMavenLifecycleParticipant { - @Requirement(optional = false) - protected QuarkusBootstrapProvider bootstrapProvider; + private final QuarkusBootstrapProvider bootstrapProvider; private boolean enabled; + @Inject + public BootstrapSessionListener(QuarkusBootstrapProvider bootstrapProvider) { + this.bootstrapProvider = bootstrapProvider; + } + @Override public void afterSessionEnd(MavenSession session) throws MavenExecutionException { try { diff --git a/devtools/maven/src/main/java/io/quarkus/maven/components/MavenVersionEnforcer.java b/devtools/maven/src/main/java/io/quarkus/maven/components/MavenVersionEnforcer.java index 5e24a782b485b..be28b95eb5795 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/components/MavenVersionEnforcer.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/components/MavenVersionEnforcer.java @@ -5,14 +5,15 @@ import java.util.List; import java.util.Properties; +import javax.inject.Named; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.versioning.*; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.component.annotations.Component; -@Component(role = MavenVersionEnforcer.class, instantiationStrategy = "per-lookup") +@Named public class MavenVersionEnforcer { public void ensureMavenVersion(Log log, MavenSession session) throws MojoExecutionException { diff --git a/independent-projects/bootstrap/maven-plugin/pom.xml b/independent-projects/bootstrap/maven-plugin/pom.xml index 0ec515e97208e..64f607b398a15 100644 --- a/independent-projects/bootstrap/maven-plugin/pom.xml +++ b/independent-projects/bootstrap/maven-plugin/pom.xml @@ -13,16 +13,15 @@ - org.codehaus.plexus - plexus-component-metadata - 2.1.0 - - ${basedir}/target/filtered-resources/META-INF/plexus - + org.eclipse.sisu + sisu-maven-plugin + 0.3.5 + index-project - generate-metadata + main-index + test-index @@ -101,6 +100,10 @@ test-jar test + + javax.inject + javax.inject + org.apache.maven maven-plugin-api diff --git a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java index 59b9190242ce2..4cb19bf05d6af 100644 --- a/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java +++ b/independent-projects/bootstrap/maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java @@ -3,7 +3,9 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; + import org.jboss.logging.Logger; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; @@ -11,7 +13,8 @@ import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace; -@Component(role = BootstrapWorkspaceProvider.class, instantiationStrategy = "singleton") +@Singleton +@Named public class BootstrapWorkspaceProvider { private final Path base; diff --git a/independent-projects/extension-maven-plugin/pom.xml b/independent-projects/extension-maven-plugin/pom.xml index 97341ee50be5f..0da59ef94671b 100644 --- a/independent-projects/extension-maven-plugin/pom.xml +++ b/independent-projects/extension-maven-plugin/pom.xml @@ -166,16 +166,15 @@ - org.codehaus.plexus - plexus-component-metadata - 2.1.0 - - ${basedir}/target/filtered-resources/META-INF/plexus - + org.eclipse.sisu + sisu-maven-plugin + 0.3.5 + index-project - generate-metadata + main-index + test-index @@ -251,6 +250,10 @@ + + javax.inject + javax.inject + org.apache.maven maven-plugin-api diff --git a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java index 7ef100f4e1c16..41d87190b51ae 100644 --- a/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java +++ b/independent-projects/extension-maven-plugin/src/main/java/io/quarkus/maven/BootstrapWorkspaceProvider.java @@ -3,7 +3,9 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; + import org.jboss.logging.Logger; import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException; @@ -11,7 +13,8 @@ import io.quarkus.bootstrap.resolver.maven.workspace.LocalProject; import io.quarkus.bootstrap.resolver.maven.workspace.LocalWorkspace; -@Component(role = BootstrapWorkspaceProvider.class, instantiationStrategy = "singleton") +@Singleton +@Named public class BootstrapWorkspaceProvider { private final Path base;