From a4c259406e6b65aa9764a7264644871802188974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Wed, 19 Jun 2024 17:51:40 +0300 Subject: [PATCH] Switch to JSR330 The following plugins and components are switched tycho-apitools-plugin, tycho-baseline-plugin, tycho-bnd-plugin, tycho-build are migrated. --- tycho-apitools-plugin/pom.xml | 12 ++++++++--- .../ApiAnnotationsClasspathContributor.java | 7 +++---- .../apitools/ApiApplicationResolver.java | 19 +++++++++--------- tycho-baseline-plugin/pom.xml | 6 +++--- .../BundleArtifactBaselineComparator.java | 15 ++++++++------ .../baseline/FeatureBaselineComparator.java | 20 +++++++++++-------- tycho-bnd-plugin/pom.xml | 6 +++--- .../maven/BndMavenLifecycleParticipant.java | 13 +++++++----- .../maven/BndProjectExecutionListener.java | 7 +++++-- tycho-build/pom.xml | 7 +++---- .../build/DefaultBuildTimestampProvider.java | 7 +++++-- .../tycho/build/TychoCiFriendlyVersions.java | 6 ++++-- .../tycho/build/TychoGraphBuilder.java | 15 ++++++++------ .../tycho/build/bnd/BndProjectMapping.java | 13 +++++------- .../tycho/build/bnd/BndWorkspaceMapping.java | 8 +++++--- .../jgit/JGitBuildTimestampProvider.java | 14 ++++++++----- 16 files changed, 101 insertions(+), 74 deletions(-) diff --git a/tycho-apitools-plugin/pom.xml b/tycho-apitools-plugin/pom.xml index d6b4e2613c..5fb41e166a 100644 --- a/tycho-apitools-plugin/pom.xml +++ b/tycho-apitools-plugin/pom.xml @@ -90,13 +90,19 @@ asm-util ${asm.version} + + javax.inject + javax.inject + 1 + provided + - org.codehaus.plexus - plexus-component-metadata - + org.eclipse.sisu + sisu-maven-plugin + org.apache.maven.plugins maven-plugin-plugin diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnnotationsClasspathContributor.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnnotationsClasspathContributor.java index e1560017db..a560ec2a20 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnnotationsClasspathContributor.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnnotationsClasspathContributor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Christoph Läubrich and others. + * Copyright (c) 2023, 2024 Christoph Läubrich and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -15,19 +15,18 @@ import java.util.Optional; import javax.inject.Inject; +import javax.inject.Named; import org.apache.maven.SessionScoped; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Component; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; -import org.eclipse.tycho.classpath.ClasspathContributor; import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.osgitools.AbstractSpecificationClasspathContributor; import org.eclipse.tycho.model.project.EclipseProject; import org.osgi.framework.VersionRange; -@Component(role = ClasspathContributor.class, hint = "apitools-annotations") +@Named("apitools-annotations") @SessionScoped public class ApiAnnotationsClasspathContributor extends AbstractSpecificationClasspathContributor { diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java index ddc2b1c6b7..4337c6b60b 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 Christoph Läubrich and others. + * Copyright (c) 2023, 2024 Christoph Läubrich and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -18,9 +18,10 @@ import java.util.List; import java.util.Set; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.Logger; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.IllegalArtifactReferenceException; @@ -41,16 +42,14 @@ * Component that resolves the bundles that make up the ApiApplication from a * given URI */ -@Component(role = ApiApplicationResolver.class) +@Named +@Singleton public class ApiApplicationResolver { - @Requirement - private Logger logger; - - @Requirement + @Inject private EclipseApplicationFactory applicationFactory; - @Requirement + @Inject private EclipseApplicationManager applicationManager; public Collection getApiBaselineBundles(Collection baselineRepoLocations, diff --git a/tycho-baseline-plugin/pom.xml b/tycho-baseline-plugin/pom.xml index 5acee8e8ba..4826a1d810 100644 --- a/tycho-baseline-plugin/pom.xml +++ b/tycho-baseline-plugin/pom.xml @@ -57,9 +57,9 @@ - org.codehaus.plexus - plexus-component-metadata - + org.eclipse.sisu + sisu-maven-plugin + org.apache.maven.plugins maven-plugin-plugin diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java index b91eec903b..f674d4d0e2 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Christoph Läubrich and others. + * Copyright (c) 2022, 2024 Christoph Läubrich and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -32,11 +32,13 @@ import java.util.jar.Manifest; import java.util.stream.Collectors; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.commons.io.FilenameUtils; 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.codehaus.plexus.logging.Logger; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.VersionRange; @@ -75,7 +77,8 @@ import de.vandermeer.asciitable.AsciiTable; import de.vandermeer.skb.interfaces.transformers.textformat.TextAlignment; -@Component(role = ArtifactBaselineComparator.class, hint = ArtifactType.TYPE_ECLIPSE_PLUGIN) +@Named(ArtifactType.TYPE_ECLIPSE_PLUGIN) +@Singleton public class BundleArtifactBaselineComparator implements ArtifactBaselineComparator { private static final String X_INTERNAL_ATTRIBUTE = "x-internal"; @@ -86,10 +89,10 @@ public class BundleArtifactBaselineComparator implements ArtifactBaselineCompara private static final int WIDTH = 160; - @Requirement + @Inject private P2RepositoryManager repositoryManager; - @Requirement(role = ContentsComparator.class) + @Inject Map contentComparators; @Override diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java index 230561832b..1c1d0b4c05 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2022 Christoph Läubrich and others. + * Copyright (c) 2022, 2024 Christoph Läubrich and others. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -29,11 +29,13 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.artifact.Artifact; 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.codehaus.plexus.logging.Logger; import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.p2.metadata.IInstallableUnit; @@ -78,7 +80,8 @@ * will be considered a micro change *
    */ -@Component(role = ArtifactBaselineComparator.class, hint = ArtifactType.TYPE_ECLIPSE_FEATURE) +@Named(ArtifactType.TYPE_ECLIPSE_FEATURE) +@Singleton public class FeatureBaselineComparator implements ArtifactBaselineComparator { private static final int WIDTH = 160; @@ -86,16 +89,17 @@ public class FeatureBaselineComparator implements ArtifactBaselineComparator { private static final String GROUP_SUFFIX = ".feature.group"; private static final String JAR_SUFFIX = ".feature.jar"; - @Requirement(hint = "zip") + @Named("zip") + @Inject ContentsComparator zipComparator; - @Requirement + @Inject MetadataIO metadataIO; - @Requirement + @Inject P2Generator p2generator; - @Requirement + @Inject P2RepositoryManager repositoryManager; @Override diff --git a/tycho-bnd-plugin/pom.xml b/tycho-bnd-plugin/pom.xml index 7df3bcade2..84ad7788d7 100644 --- a/tycho-bnd-plugin/pom.xml +++ b/tycho-bnd-plugin/pom.xml @@ -52,9 +52,9 @@ - org.codehaus.plexus - plexus-component-metadata - + org.eclipse.sisu + sisu-maven-plugin + org.apache.maven.plugins maven-plugin-plugin diff --git a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndMavenLifecycleParticipant.java b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndMavenLifecycleParticipant.java index 3e197b0b95..7b22f6967c 100644 --- a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndMavenLifecycleParticipant.java +++ b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndMavenLifecycleParticipant.java @@ -24,14 +24,16 @@ import java.util.jar.Manifest; import java.util.stream.Collectors; +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.artifact.Artifact; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.tycho.core.bnd.BndPluginManager; @@ -51,7 +53,8 @@ * test maven dependency *
*/ -@Component(role = AbstractMavenLifecycleParticipant.class) +@Named +@Singleton public class BndMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { private static final Set> BND_TO_MAVEN_MAPPING = Map.of(// @@ -60,10 +63,10 @@ public class BndMavenLifecycleParticipant extends AbstractMavenLifecycleParticip Constants.TESTPATH, Artifact.SCOPE_TEST // ).entrySet(); - @Requirement + @Inject private Logger logger; - @Requirement + @Inject private BndPluginManager bndPluginManager; @Override diff --git a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndProjectExecutionListener.java b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndProjectExecutionListener.java index 4cbc20c79e..8b282a4d5f 100644 --- a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndProjectExecutionListener.java +++ b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/maven/BndProjectExecutionListener.java @@ -15,13 +15,16 @@ import java.util.Iterator; import java.util.List; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.execution.ProjectExecutionEvent; import org.apache.maven.execution.ProjectExecutionListener; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.plugin.MojoExecution; -import org.codehaus.plexus.component.annotations.Component; -@Component(role = ProjectExecutionListener.class) +@Named +@Singleton public class BndProjectExecutionListener implements ProjectExecutionListener { @Override diff --git a/tycho-build/pom.xml b/tycho-build/pom.xml index d7d8c2e866..5c9d3074f3 100644 --- a/tycho-build/pom.xml +++ b/tycho-build/pom.xml @@ -11,10 +11,9 @@ - org.codehaus.plexus - plexus-component-metadata - - + org.eclipse.sisu + sisu-maven-plugin +
diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/DefaultBuildTimestampProvider.java b/tycho-build/src/main/java/org/eclipse/tycho/build/DefaultBuildTimestampProvider.java index 731fefebbb..eb14a54463 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/DefaultBuildTimestampProvider.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/DefaultBuildTimestampProvider.java @@ -14,16 +14,19 @@ import java.util.Date; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Component; /** * Build timestamp provider that returns the same timestamp for all projects, the * ${maven.build.timestamp}. */ -@Component(role = BuildTimestampProvider.class, hint = DefaultBuildTimestampProvider.ROLE_HINT) +@Named(DefaultBuildTimestampProvider.ROLE_HINT) +@Singleton public class DefaultBuildTimestampProvider implements BuildTimestampProvider { static final String ROLE_HINT = "default"; diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoCiFriendlyVersions.java b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoCiFriendlyVersions.java index a206985e9d..2ecb5d860f 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoCiFriendlyVersions.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoCiFriendlyVersions.java @@ -26,6 +26,8 @@ //import javax.annotation.Priority; import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; import org.apache.maven.execution.DefaultMavenExecutionRequest; import org.apache.maven.execution.DefaultMavenExecutionResult; @@ -42,7 +44,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; @@ -51,7 +52,8 @@ import org.eclipse.tycho.TychoConstants; @Priority(100) -@Component(role = ModelVersionProcessor.class) +@Named +@Singleton public class TychoCiFriendlyVersions extends DefaultModelVersionProcessor implements ModelVersionProcessor { static final String PROPERTY_FORCE_QUALIFIER = "forceContextQualifier"; diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java index 1100f3ff40..4150c78e9e 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/TychoGraphBuilder.java @@ -33,6 +33,10 @@ import java.util.function.Function; import java.util.stream.Collectors; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.ProjectDependencyGraph; @@ -46,8 +50,6 @@ import org.apache.maven.model.building.Result; import org.apache.maven.project.DuplicateProjectException; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.eclipse.core.runtime.CoreException; @@ -61,17 +63,18 @@ import org.eclipse.tycho.pomless.AbstractTychoMapping; import org.sonatype.maven.polyglot.mapping.Mapping; -@Component(role = GraphBuilder.class, hint = GraphBuilder.HINT) +@Named(GraphBuilder.HINT) +@Singleton public class TychoGraphBuilder extends DefaultGraphBuilder { private static final boolean DEBUG = Boolean.getBoolean("tycho.graphbuilder.debug"); - @Requirement + @Inject private Logger log; - @Requirement(role = Mapping.class) + @Inject private Map polyglotMappings; - @Requirement + @Inject private MavenProjectDependencyProcessor dependencyProcessor; @Override diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndProjectMapping.java b/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndProjectMapping.java index 399e14f8f0..25f48ea51b 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndProjectMapping.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndProjectMapping.java @@ -16,28 +16,25 @@ import java.io.IOException; import java.io.Reader; import java.nio.file.Path; -import java.util.Map; -import org.apache.maven.lifecycle.Lifecycle; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.pomless.AbstractTychoMapping; import org.eclipse.tycho.version.TychoVersion; -import org.sonatype.maven.polyglot.mapping.Mapping; import aQute.bnd.build.Project; import aQute.bnd.build.Workspace; -@Component(role = Mapping.class, hint = "bnd") +@Named("bnd") +@Singleton public class BndProjectMapping extends AbstractTychoMapping { private static final String TYCHO_BND_PLUGIN = "tycho-bnd-plugin"; - @Requirement(role = Lifecycle.class) - private Map lifecycles; @Override public float getPriority() { diff --git a/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndWorkspaceMapping.java b/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndWorkspaceMapping.java index e42f70cf3a..f2ab25158f 100644 --- a/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndWorkspaceMapping.java +++ b/tycho-build/src/main/java/org/eclipse/tycho/build/bnd/BndWorkspaceMapping.java @@ -22,18 +22,20 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.model.Model; -import org.codehaus.plexus.component.annotations.Component; import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.pomless.AbstractTychoMapping; import org.eclipse.tycho.pomless.NoParentPomFound; import org.eclipse.tycho.pomless.ParentModel; -import org.sonatype.maven.polyglot.mapping.Mapping; import aQute.bnd.build.Project; import aQute.bnd.build.Workspace; -@Component(role = Mapping.class, hint = "bnd-workspace") +@Named("bnd-workspace") +@Singleton public class BndWorkspaceMapping extends AbstractTychoMapping { private Map> modulesCache = new ConcurrentHashMap>(); diff --git a/tycho-buildtimestamp-jgit/src/main/java/org/eclipse/tycho/extras/buildtimestamp/jgit/JGitBuildTimestampProvider.java b/tycho-buildtimestamp-jgit/src/main/java/org/eclipse/tycho/extras/buildtimestamp/jgit/JGitBuildTimestampProvider.java index 3b0310fe8c..835d04c0fd 100644 --- a/tycho-buildtimestamp-jgit/src/main/java/org/eclipse/tycho/extras/buildtimestamp/jgit/JGitBuildTimestampProvider.java +++ b/tycho-buildtimestamp-jgit/src/main/java/org/eclipse/tycho/extras/buildtimestamp/jgit/JGitBuildTimestampProvider.java @@ -22,12 +22,14 @@ import java.util.List; import java.util.Set; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; 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.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; @@ -91,16 +93,18 @@ * ... * */ -@Component(role = BuildTimestampProvider.class, hint = "jgit") +@Named("jgit") +@Singleton public class JGitBuildTimestampProvider implements BuildTimestampProvider { private static final String PARAMETER_JGIT_IGNORE = "jgit.ignore"; private static final String PARAMETER_JGIT_DIRTY_WORKING_TREE = "jgit.dirtyWorkingTree"; - @Requirement(hint = "default") + @Named("default") + @Inject private BuildTimestampProvider defaultTimestampProvider; - @Requirement + @Inject private Logger logger; private boolean quiet;