From 1b3f82919fdd82f515abb5538dd8336d35ae62c3 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Tue, 16 Dec 2014 08:59:52 +0100 Subject: [PATCH 1/4] Port to Maven 3.0.5 Porting to Maven 3.0.5 also means migrating to some other libraries and technologies which are used by Maven: Eclipse Aether -> Sonatype Aether Eclipse Sisu Inject -> Sonatype Sisu Plexus JSR-330 -> Plexus Component Annotations --- pom.xml | 10 ++ xmvn-connector-aether/pom.xml | 14 +- .../connector/aether/XMvnBuildPluginManager.java | 178 +++++++++++++++++++++ .../aether/XMvnMavenLifecycleParticipant.java | 19 +-- .../xmvn/connector/aether/XMvnModelValidator.java | 23 +-- .../aether/XMvnMojoExecutionListener.java | 42 +---- .../aether/XMvnPluginVersionResolver.java | 15 +- .../xmvn/connector/aether/XMvnWorkspaceReader.java | 24 +-- .../xmvn/connector/aether/PlexusTest.java | 2 +- xmvn-core/pom.xml | 8 +- .../config/impl/DefaultConfigurationMerger.java | 7 +- .../xmvn/config/impl/DefaultConfigurator.java | 17 +- .../xmvn/deployer/impl/DefaultDeployer.java | 7 +- .../xmvn/locator/XMvnServiceLocator.java | 54 ++++--- .../xmvn/resolver/impl/DefaultResolver.java | 33 ++-- .../resolver/impl/LocalRepositoryResolver.java | 6 +- .../impl/depmap/CompoundRepositoryFactory.java | 18 +-- .../resolver/impl/depmap/DefaultDependencyMap.java | 15 +- .../impl/depmap/DefaultRepositoryConfigurator.java | 22 +-- .../impl/depmap/DepmapBasedArtifactBlacklist.java | 25 ++- .../resolver/impl/depmap/DepmapBasedResolver.java | 27 ++-- .../impl/depmap/FlatRepositoryFactory.java | 6 +- .../resolver/impl/depmap/JppRepositoryFactory.java | 6 +- .../impl/depmap/MavenRepositoryFactory.java | 6 +- .../xmvn/deployer/BasicDeployerTest.java | 6 +- .../xmvn/resolver/BasicResolverTest.java | 7 +- .../xmvn/resolver/BisectResolverTest.java | 12 +- .../xmvn/resolver/JavaHomeResolverTest.java | 8 +- .../xmvn/resolver/TestConfigurator.java | 15 +- .../xmvn/resolver/impl/depmap/DepmapTest.java | 7 +- xmvn-mojo/pom.xml | 8 +- .../dependency/impl/BuildDependencyExtractor.java | 17 +- .../impl/RuntimeDependencyExtractor.java | 17 +- .../xmvn/model/impl/DefaultModelProcessor.java | 18 +-- .../xmvn/model/impl/DefaultModelReader.java | 7 +- .../org/fedoraproject/xmvn/mojo/BuilddepMojo.java | 19 +-- .../org/fedoraproject/xmvn/mojo/InstallMojo.java | 19 +-- .../java/org/fedoraproject/xmvn/mojo/Utils.java | 4 +- .../xmvn/dependency/AbstractDependencyTest.java | 8 +- .../dependency/RuntimeDependencyExtractorTest.java | 6 +- .../xmvn/mojo/DirectoryInstallationTest.java | 3 +- .../xmvn/mojo/NullFileInstallationTest.java | 3 +- xmvn-parent/pom.xml | 49 +++--- xmvn-tools/pom.xml | 4 +- xmvn-tools/xmvn-bisect/pom.xml | 4 +- .../fedoraproject/xmvn/tools/bisect/BisectCli.java | 32 ++-- .../xmvn/tools/bisect/DefaultBuildExecutor.java | 7 +- .../repository/impl/CompoundRepositoryFactory.java | 19 +-- .../impl/DefaultRepositoryConfigurator.java | 22 +-- .../xmvn/repository/impl/JppRepositoryFactory.java | 8 +- .../repository/impl/MavenRepositoryFactory.java | 8 +- .../xmvn/tools/install/cli/InstallerCli.java | 32 ++-- .../install/impl/ArtifactInstallerFactory.java | 16 +- .../install/impl/DefaultArtifactInstaller.java | 16 +- .../xmvn/tools/install/impl/DefaultInstaller.java | 29 +++- .../xmvn/repository/CustomRepositoryTest.java | 7 +- .../xmvn/repository/DefaultConfigurator.java | 7 +- .../xmvn/repository/JppRepositoryTest.java | 7 +- .../fedoraproject/xmvn/repository/LayoutTest.java | 11 +- .../xmvn/repository/MavenRepositoryTest.java | 8 +- .../xmvn/repository/MyRepositoryFactory.java | 7 +- .../xmvn/tools/install/AbstractInstallerTest.java | 2 - .../xmvn/tools/install/ArtifactInstallerTest.java | 23 ++- .../xmvn/tools/install/InstallerTest.java | 30 ++-- .../tools/install/impl/EffectivePackagingTest.java | 9 +- .../xmvn/tools/resolve/ResolverCli.java | 30 ++-- xmvn-tools/xmvn-subst/pom.xml | 4 +- .../xmvn/tools/subst/ArtifactVisitor.java | 18 +-- .../fedoraproject/xmvn/tools/subst/SubstCli.java | 31 ++-- 69 files changed, 562 insertions(+), 646 deletions(-) create mode 100644 xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnBuildPluginManager.java diff --git a/pom.xml b/pom.xml index 5e655e0..46142c5 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,16 @@ xmvn-connector-aether runtime + + org.slf4j + slf4j-api + runtime + + + org.slf4j + slf4j-simple + runtime + diff --git a/xmvn-connector-aether/pom.xml b/xmvn-connector-aether/pom.xml index 1597ef4..eec50d4 100644 --- a/xmvn-connector-aether/pom.xml +++ b/xmvn-connector-aether/pom.xml @@ -54,12 +54,16 @@ maven-artifact - org.eclipse.aether + org.sonatype.aether aether-api - javax.inject - javax.inject + org.sonatype.aether + aether-util + + + org.codehaus.plexus + plexus-component-annotations org.codehaus.plexus @@ -70,8 +74,8 @@ xmvn-core - org.eclipse.sisu - org.eclipse.sisu.inject + org.sonatype.sisu + sisu-inject-plexus org.sonatype.sisu diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnBuildPluginManager.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnBuildPluginManager.java new file mode 100644 index 0000000..f44bff9 --- /dev/null +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnBuildPluginManager.java @@ -0,0 +1,178 @@ +package org.fedoraproject.xmvn.connector.aether; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.List; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.BuildPluginManager; +import org.apache.maven.plugin.DefaultBuildPluginManager; +import org.apache.maven.plugin.InvalidPluginDescriptorException; +import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.MavenPluginManager; +import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.MojoNotFoundException; +import org.apache.maven.plugin.PluginConfigurationException; +import org.apache.maven.plugin.PluginContainerException; +import org.apache.maven.plugin.PluginDescriptorParsingException; +import org.apache.maven.plugin.PluginExecutionException; +import org.apache.maven.plugin.PluginManagerException; +import org.apache.maven.plugin.PluginNotFoundException; +import org.apache.maven.plugin.PluginResolutionException; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.sonatype.aether.RepositorySystemSession; +import org.sonatype.aether.repository.RemoteRepository; + +@Component( role = BuildPluginManager.class ) +public class XMvnBuildPluginManager + extends DefaultBuildPluginManager +{ + @Requirement + private MavenPluginManager mavenPluginManager; + + @Requirement + private LegacySupport legacySupport; + + private final XMvnMojoExecutionListener listener; + + public XMvnBuildPluginManager() + { + listener = new XMvnMojoExecutionListener(); + } + + @Override + public PluginDescriptor loadPlugin( Plugin plugin, List repositories, + RepositorySystemSession session ) + throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, + InvalidPluginDescriptorException + { + return mavenPluginManager.getPluginDescriptor( plugin, repositories, session ); + } + + @Override + @SuppressWarnings( "resource" ) + public void executeMojo( MavenSession session, MojoExecution mojoExecution ) + throws MojoFailureException, MojoExecutionException, PluginConfigurationException, PluginManagerException + { + MavenProject project = session.getCurrentProject(); + + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + + Mojo mojo = null; + + ClassRealm pluginRealm; + try + { + pluginRealm = getPluginRealm( session, mojoDescriptor.getPluginDescriptor() ); + } + catch ( PluginResolutionException e ) + { + throw new PluginExecutionException( mojoExecution, project, e ); + } + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader( pluginRealm ); + + MavenSession oldSession = legacySupport.getSession(); + + try + { + mojo = mavenPluginManager.getConfiguredMojo( Mojo.class, session, mojoExecution ); + + legacySupport.setSession( session ); + + try + { + mojo.execute(); + + listener.afterMojoExecutionSuccess( mojo, mojoExecution, project ); + } + catch ( ClassCastException e ) + { + throw e; + } + catch ( RuntimeException e ) + { + throw new PluginExecutionException( mojoExecution, project, e ); + } + } + catch ( PluginContainerException e ) + { + throw new PluginExecutionException( mojoExecution, project, e ); + } + catch ( NoClassDefFoundError e ) + { + ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); + PrintStream ps = new PrintStream( os ); + ps.println( "A required class was missing while executing " + mojoDescriptor.getId() + ": " + + e.getMessage() ); + pluginRealm.display( ps ); + + Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e ); + + throw new PluginExecutionException( mojoExecution, project, wrapper ); + } + catch ( LinkageError e ) + { + ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); + PrintStream ps = new PrintStream( os ); + ps.println( "An API incompatibility was encountered while executing " + mojoDescriptor.getId() + ": " + + e.getClass().getName() + ": " + e.getMessage() ); + pluginRealm.display( ps ); + + Exception wrapper = new PluginContainerException( mojoDescriptor, pluginRealm, os.toString(), e ); + throw new PluginExecutionException( mojoExecution, project, wrapper ); + } + catch ( ClassCastException e ) + { + ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); + PrintStream ps = new PrintStream( os ); + ps.println( "A type incompatibility occured while executing " + mojoDescriptor.getId() + ": " + + e.getMessage() ); + pluginRealm.display( ps ); + + throw new PluginExecutionException( mojoExecution, project, os.toString(), e ); + } + finally + { + mavenPluginManager.releaseMojo( mojo, mojoExecution ); + + Thread.currentThread().setContextClassLoader( oldClassLoader ); + + legacySupport.setSession( oldSession ); + } + } + + @Override + public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor ) + throws PluginResolutionException, PluginManagerException + { + ClassRealm pluginRealm = pluginDescriptor.getClassRealm(); + if ( pluginRealm != null ) + { + return pluginRealm; + } + + mavenPluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); + + return pluginDescriptor.getClassRealm(); + } + + @Override + public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List repositories, + RepositorySystemSession session ) + throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, + MojoNotFoundException, InvalidPluginDescriptorException + { + return mavenPluginManager.getMojoDescriptor( plugin, goal, repositories, session ); + } +} diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java index 0a91508..2b8c202 100644 --- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMavenLifecycleParticipant.java @@ -15,32 +15,25 @@ */ package org.fedoraproject.xmvn.connector.aether; -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.MavenExecutionRequest; import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.sonatype.aether.repository.WorkspaceReader; /** * Installs some of XMvn extensions for Maven. * * @author Mikolaj Izdebski */ -@Named( "XMvn" ) -@Singleton +@Component( role = AbstractMavenLifecycleParticipant.class, hint = "XMvn" ) public class XMvnMavenLifecycleParticipant extends AbstractMavenLifecycleParticipant { - private final XMvnWorkspaceReader workspaceReader; - - @Inject - public XMvnMavenLifecycleParticipant( XMvnWorkspaceReader workspaceReader ) - { - this.workspaceReader = workspaceReader; - } + @Requirement( role = WorkspaceReader.class, hint = "ide" ) + private XMvnWorkspaceReader workspaceReader; @Override public void afterSessionStart( MavenSession session ) diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnModelValidator.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnModelValidator.java index 0961361..64772e6 100644 --- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnModelValidator.java +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnModelValidator.java @@ -20,10 +20,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Build; @@ -35,6 +31,9 @@ import org.apache.maven.model.PluginExecution; import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.validation.DefaultModelValidator; +import org.apache.maven.model.validation.ModelValidator; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.slf4j.Logger; @@ -50,23 +49,17 @@ import org.fedoraproject.xmvn.resolver.ArtifactBlacklist; * * @author Mikolaj Izdebski */ -@Named( "default" ) -@Singleton +@Component( role = ModelValidator.class ) public class XMvnModelValidator extends DefaultModelValidator { private final Logger logger = LoggerFactory.getLogger( XMvnModelValidator.class ); - private final Configurator configurator; - - private final ArtifactBlacklist blacklist; + @Requirement + private Configurator configurator; - @Inject - public XMvnModelValidator( Configurator configurator, ArtifactBlacklist blacklist ) - { - this.configurator = configurator; - this.blacklist = blacklist; - } + @Requirement + private ArtifactBlacklist blacklist; @Override public void validateEffectiveModel( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java index a9cac0e..b0b8400 100644 --- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionListener.java @@ -24,14 +24,8 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Properties; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.apache.maven.execution.MojoExecutionEvent; -import org.apache.maven.execution.MojoExecutionListener; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; /** @@ -39,10 +33,7 @@ import org.apache.maven.project.MavenProject; * * @author Mikolaj Izdebski */ -@Named -@Singleton -public class XMvnMojoExecutionListener - implements MojoExecutionListener +class XMvnMojoExecutionListener { private static class MojoGoal { @@ -86,7 +77,6 @@ public class XMvnMojoExecutionListener private static final Path PROPERTIES_FILE = XMVN_STATE_DIR.resolve( "properties" ); private static String getBeanProperty( Object bean, String getterName ) - throws MojoExecutionException { try { @@ -104,16 +94,15 @@ public class XMvnMojoExecutionListener } } - throw new MojoExecutionException( "Unable to find bean property getter method " + getterName ); + throw new RuntimeException( "Unable to find bean property getter method " + getterName ); } catch ( ReflectiveOperationException e ) { - throw new MojoExecutionException( "Failed to get bean property", e ); + throw new RuntimeException( "Failed to get bean property", e ); } } private static void createApidocsSymlink( Path javadocDir ) - throws MojoExecutionException { try { @@ -127,12 +116,11 @@ public class XMvnMojoExecutionListener } catch ( IOException e ) { - throw new MojoExecutionException( "Failed to create apidocs symlink", e ); + throw new RuntimeException( "Failed to create apidocs symlink", e ); } } private void setProjectProperty( MavenProject project, String key, String value ) - throws MojoExecutionException { Properties properties = new Properties(); @@ -159,18 +147,12 @@ public class XMvnMojoExecutionListener } catch ( IOException e ) { - throw new MojoExecutionException( "Failed to set project property", e ); + throw new RuntimeException( "Failed to set project property", e ); } } - @Override - public void afterMojoExecutionSuccess( MojoExecutionEvent event ) - throws MojoExecutionException + public void afterMojoExecutionSuccess( Mojo mojo, MojoExecution execution, MavenProject project ) { - Mojo mojo = event.getMojo(); - MojoExecution execution = event.getExecution(); - MavenProject project = event.getProject(); - if ( JAVADOC_AGGREGATE.equals( execution ) ) { String javadocDir = getBeanProperty( mojo, "getReportOutputDirectory" ); @@ -187,16 +169,4 @@ public class XMvnMojoExecutionListener setProjectProperty( project, "compilerTarget", getBeanProperty( mojo, "getTargetLevel" ) ); } } - - @Override - public void beforeMojoExecution( MojoExecutionEvent event ) - { - // Nothing to do - } - - @Override - public void afterExecutionFailure( MojoExecutionEvent event ) - { - // Nothing to do - } } diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnPluginVersionResolver.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnPluginVersionResolver.java index 6180e4a..d59c019 100644 --- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnPluginVersionResolver.java +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnPluginVersionResolver.java @@ -17,24 +17,21 @@ package org.fedoraproject.xmvn.connector.aether; import java.util.List; -import javax.inject.Named; -import javax.inject.Singleton; - import org.apache.maven.plugin.version.PluginVersionRequest; import org.apache.maven.plugin.version.PluginVersionResolver; import org.apache.maven.plugin.version.PluginVersionResult; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.repository.ArtifactRepository; -import org.eclipse.aether.repository.WorkspaceReader; +import org.codehaus.plexus.component.annotations.Component; +import org.sonatype.aether.RepositorySystemSession; +import org.sonatype.aether.repository.ArtifactRepository; +import org.sonatype.aether.repository.WorkspaceReader; +import org.sonatype.aether.util.artifact.DefaultArtifact; import org.fedoraproject.xmvn.artifact.Artifact; /** * @author Mikolaj Izdebski */ -@Named( "default" ) -@Singleton +@Component( role = PluginVersionResolver.class ) public class XMvnPluginVersionResolver implements PluginVersionResolver { diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnWorkspaceReader.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnWorkspaceReader.java index b1a8649..7ee0629 100644 --- a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnWorkspaceReader.java +++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnWorkspaceReader.java @@ -21,13 +21,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.repository.WorkspaceReader; -import org.eclipse.aether.repository.WorkspaceRepository; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.sonatype.aether.artifact.Artifact; +import org.sonatype.aether.repository.WorkspaceReader; +import org.sonatype.aether.repository.WorkspaceRepository; import org.fedoraproject.xmvn.resolver.ResolutionRequest; import org.fedoraproject.xmvn.resolver.ResolutionResult; @@ -36,23 +34,17 @@ import org.fedoraproject.xmvn.resolver.Resolver; /** * @author Mikolaj Izdebski */ -@Named( "ide" ) -@Singleton +@Component( role = WorkspaceReader.class, hint = "ide" ) public class XMvnWorkspaceReader implements WorkspaceReader { - private final Resolver resolver; + @Requirement + private Resolver resolver; private static final WorkspaceRepository repository = new WorkspaceRepository(); private final List listeners = new ArrayList<>(); - @Inject - public XMvnWorkspaceReader( Resolver resolver ) - { - this.resolver = resolver; - } - public void addResolutionListener( ResolutionListener listener ) { listeners.add( listener ); diff --git a/xmvn-connector-aether/src/test/java/org/fedoraproject/xmvn/connector/aether/PlexusTest.java b/xmvn-connector-aether/src/test/java/org/fedoraproject/xmvn/connector/aether/PlexusTest.java index b2caf42..089c44e 100644 --- a/xmvn-connector-aether/src/test/java/org/fedoraproject/xmvn/connector/aether/PlexusTest.java +++ b/xmvn-connector-aether/src/test/java/org/fedoraproject/xmvn/connector/aether/PlexusTest.java @@ -23,8 +23,8 @@ import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; -import org.eclipse.aether.repository.WorkspaceReader; import org.junit.Test; +import org.sonatype.aether.repository.WorkspaceReader; /** * @author Mikolaj Izdebski diff --git a/xmvn-core/pom.xml b/xmvn-core/pom.xml index 1c1808a..2792c5b 100644 --- a/xmvn-core/pom.xml +++ b/xmvn-core/pom.xml @@ -38,12 +38,12 @@ xmvn-api - javax.inject - javax.inject + org.codehaus.plexus + plexus-component-annotations - org.eclipse.sisu - org.eclipse.sisu.inject + org.sonatype.sisu + sisu-inject-plexus org.sonatype.sisu diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurationMerger.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurationMerger.java index d88b3f7..4c0d1fc 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurationMerger.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurationMerger.java @@ -19,9 +19,7 @@ import java.util.List; import java.util.Properties; import java.util.Set; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; import org.fedoraproject.xmvn.config.BuildSettings; @@ -41,8 +39,7 @@ import org.fedoraproject.xmvn.config.ResolverSettings; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = ConfigurationMerger.class ) public class DefaultConfigurationMerger implements ConfigurationMerger { diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurator.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurator.java index e1f2497..0ab1775 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurator.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/config/impl/DefaultConfigurator.java @@ -28,11 +28,10 @@ import java.util.List; import java.util.Set; import java.util.TreeSet; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.xml.stream.XMLStreamException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,14 +51,14 @@ import org.fedoraproject.xmvn.config.io.stax.ConfigurationStaxWriter; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = Configurator.class ) public class DefaultConfigurator implements Configurator { private final Logger logger = LoggerFactory.getLogger( DefaultConfigurator.class ); - private final ConfigurationMerger merger; + @Requirement + private ConfigurationMerger merger; private Configuration cachedConfiguration; @@ -67,12 +66,6 @@ public class DefaultConfigurator private List configFiles; - @Inject - public DefaultConfigurator( ConfigurationMerger merger ) - { - this.merger = merger; - } - private Configuration loadConfigurationFromStream( InputStream stream ) throws IOException { diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/deployer/impl/DefaultDeployer.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/deployer/impl/DefaultDeployer.java index 1ad9eb8..5852591 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/deployer/impl/DefaultDeployer.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/deployer/impl/DefaultDeployer.java @@ -24,10 +24,10 @@ import java.nio.file.Path; import java.util.List; import java.util.Map.Entry; -import javax.inject.Named; -import javax.inject.Singleton; import javax.xml.stream.XMLStreamException; +import org.codehaus.plexus.component.annotations.Component; + import org.fedoraproject.xmvn.artifact.Artifact; import org.fedoraproject.xmvn.deployer.Deployer; import org.fedoraproject.xmvn.deployer.DeploymentRequest; @@ -49,8 +49,7 @@ import org.fedoraproject.xmvn.utils.ArtifactUtils; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = Deployer.class ) public class DefaultDeployer implements Deployer { diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/locator/XMvnServiceLocator.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/locator/XMvnServiceLocator.java index 08dc452..d37feb3 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/locator/XMvnServiceLocator.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/locator/XMvnServiceLocator.java @@ -20,18 +20,14 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.inject.Inject; -import javax.inject.Named; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.eclipse.sisu.EagerSingleton; -import org.eclipse.sisu.space.BeanScanning; -import org.eclipse.sisu.space.ClassSpace; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.PlexusContainerException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.sonatype.guice.plexus.config.Strategies; import org.fedoraproject.xmvn.deployer.Deployer; import org.fedoraproject.xmvn.resolver.Resolver; @@ -41,22 +37,19 @@ import org.fedoraproject.xmvn.resolver.Resolver; * * @author Mikolaj Izdebski */ -@Named -@EagerSingleton +@Component( role = XMvnServiceLocator.class, instantiationStrategy = Strategies.LOAD_ON_START ) public class XMvnServiceLocator + implements Initializable { private static XMvnServiceLocator instance; private static synchronized XMvnServiceLocator getInstance() + throws PlexusContainerException, ComponentLookupException { if ( instance == null ) { - ClassLoader classRealm = XMvnServiceLocator.class.getClassLoader(); - ClassSpace classSpace = new URLClassSpace( classRealm ); - Module spaceModule = new SpaceModule( classSpace, BeanScanning.CACHE ); - Module wireModule = new WireModule( spaceModule ); - Injector injector = Guice.createInjector( wireModule ); - instance = injector.getInstance( XMvnServiceLocator.class ); + PlexusContainer container = new DefaultPlexusContainer(); + instance = container.lookup( XMvnServiceLocator.class ); } return instance; @@ -64,13 +57,19 @@ public class XMvnServiceLocator private final Map> knownServices = new HashMap<>(); + @Requirement + private List resolvers; + + @Requirement + private List deployers; + private void addService( Class service, Iterable serviceProviders ) { knownServices.put( service.getCanonicalName(), serviceProviders ); } - @Inject - public XMvnServiceLocator( List resolvers, List deployers ) + @Override + public void initialize() { addService( Resolver.class, resolvers ); addService( Deployer.class, deployers ); @@ -78,7 +77,14 @@ public class XMvnServiceLocator public static Object getService( Class role ) { - Iterator iterator = getInstance().knownServices.get( role.getCanonicalName() ).iterator(); - return iterator.hasNext() ? iterator.next() : null; + try + { + Iterator iterator = getInstance().knownServices.get( role.getCanonicalName() ).iterator(); + return iterator.hasNext() ? iterator.next() : null; + } + catch ( PlexusContainerException | ComponentLookupException e ) + { + throw new RuntimeException( "Plexus exception when trying to initialize XMvn service " + role, e ); + } } } diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/DefaultResolver.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/DefaultResolver.java index 51a759c..816dbcc 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/DefaultResolver.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/DefaultResolver.java @@ -20,10 +20,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,30 +45,30 @@ import org.fedoraproject.xmvn.utils.FileUtils; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = Resolver.class ) public class DefaultResolver - implements Resolver + implements Resolver, Initializable { private final Logger logger = LoggerFactory.getLogger( DefaultResolver.class ); - private final MetadataResolver metadataResolver; + private MetadataResolver metadataResolver; private static final RpmDb rpmdb = new RpmDb(); - private final Resolver localRepoResolver; + @Requirement( hint = "local-repo" ) + private Resolver localRepoResolver; - private final Resolver depmapResolver; + @Requirement( hint = "depmap" ) + private Resolver depmapResolver; - private final EffectivePomGenerator pomGenerator; + private EffectivePomGenerator pomGenerator; - @Inject - public DefaultResolver( @Named( "local-repo" ) Resolver localRepoResolver, - @Named( "depmap" ) Resolver depmapResolver, Configurator configurator ) - { - this.localRepoResolver = localRepoResolver; - this.depmapResolver = depmapResolver; + @Requirement + private Configurator configurator; + @Override + public void initialize() + { ResolverSettings settings = configurator.getConfiguration().getResolverSettings(); metadataResolver = new MetadataResolver( settings.getMetadataRepositories() ); pomGenerator = new EffectivePomGenerator(); diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/LocalRepositoryResolver.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/LocalRepositoryResolver.java index 2b51a5b..ef361b3 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/LocalRepositoryResolver.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/LocalRepositoryResolver.java @@ -19,8 +19,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; import org.fedoraproject.xmvn.artifact.Artifact; import org.fedoraproject.xmvn.resolver.ResolutionRequest; @@ -36,8 +35,7 @@ import org.fedoraproject.xmvn.resolver.Resolver; * * @author Mikolaj Izdebski */ -@Named( "local-repo" ) -@Singleton +@Component( role = Resolver.class, hint = "local-repo" ) public class LocalRepositoryResolver implements Resolver { diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/CompoundRepositoryFactory.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/CompoundRepositoryFactory.java index 1fe75a2..62be12e 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/CompoundRepositoryFactory.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/CompoundRepositoryFactory.java @@ -21,10 +21,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -39,19 +37,13 @@ import org.fedoraproject.xmvn.config.Stereotype; * * @author Mikolaj Izdebski */ -@Named( "compound" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "compound" ) @Deprecated public class CompoundRepositoryFactory extends AbstractRepositoryFactory { - private final RepositoryConfigurator configurator; - - @Inject - public CompoundRepositoryFactory( RepositoryConfigurator configurator ) - { - this.configurator = configurator; - } + @Requirement + private RepositoryConfigurator configurator; @Override public Repository getInstance( List stereotypes, Properties properties, Xpp3Dom configuration, diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultDependencyMap.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultDependencyMap.java index 9da8541..76c950c 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultDependencyMap.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultDependencyMap.java @@ -28,10 +28,8 @@ import java.util.Set; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,8 +46,7 @@ import org.fedoraproject.xmvn.utils.ArtifactUtils; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = DefaultDependencyMap.class ) @Deprecated public class DefaultDependencyMap { @@ -61,16 +58,16 @@ public class DefaultDependencyMap private final Map> reverseMapping = new LinkedHashMap<>(); + @Requirement private final Configurator configurator; private final String depmapFragmentDir; private boolean initialized; - @Inject - public DefaultDependencyMap( Configurator configurator ) + public DefaultDependencyMap() { - this( configurator, "usr/share/maven-fragments" ); + this( null, "usr/share/maven-fragments" ); } DefaultDependencyMap( Configurator configurator, String depmapFragmentDir ) diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultRepositoryConfigurator.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultRepositoryConfigurator.java index dfaa781..d87f3a7 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultRepositoryConfigurator.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DefaultRepositoryConfigurator.java @@ -19,10 +19,8 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.fedoraproject.xmvn.config.Configurator; @@ -35,22 +33,16 @@ import org.fedoraproject.xmvn.config.Stereotype; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = RepositoryConfigurator.class ) @Deprecated public class DefaultRepositoryConfigurator implements RepositoryConfigurator { - private final Configurator configurator; - - private final Map repositoryFactories; + @Requirement + private Configurator configurator; - @Inject - public DefaultRepositoryConfigurator( Configurator configurator, Map repositoryFactories ) - { - this.configurator = configurator; - this.repositoryFactories = repositoryFactories; - } + @Requirement + private Map repositoryFactories; private org.fedoraproject.xmvn.config.Repository findDescriptor( String repoId ) { diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedArtifactBlacklist.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedArtifactBlacklist.java index bfcf28c..54d3496 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedArtifactBlacklist.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedArtifactBlacklist.java @@ -19,10 +19,9 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,24 +40,22 @@ import org.fedoraproject.xmvn.utils.ArtifactUtils; * * @author Mikolaj Izdebski */ -@Named( "depmap" ) -@Singleton +@Component( role = ArtifactBlacklist.class, hint = "depmap" ) @Deprecated public class DepmapBasedArtifactBlacklist - implements ArtifactBlacklist + implements ArtifactBlacklist, Initializable { private final Logger logger = LoggerFactory.getLogger( DepmapBasedArtifactBlacklist.class ); - private final Configurator configurator; + @Requirement + private Configurator configurator; - private final DefaultDependencyMap depmap; + @Requirement + private DefaultDependencyMap depmap; - @Inject - public DepmapBasedArtifactBlacklist( Configurator configurator, DefaultDependencyMap depmap ) + @Override + public void initialize() { - this.configurator = configurator; - this.depmap = depmap; - createInitialBlacklist(); blacklistAliases(); } diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedResolver.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedResolver.java index 298b060..14f15e6 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedResolver.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapBasedResolver.java @@ -28,10 +28,9 @@ import java.util.List; import java.util.ListIterator; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,32 +53,30 @@ import org.fedoraproject.xmvn.utils.FileUtils; * * @author Mikolaj Izdebski */ -@Named( "depmap" ) -@Singleton +@Component( role = Resolver.class, hint = "depmap" ) @Deprecated public class DepmapBasedResolver - implements Resolver + implements Resolver, Initializable { private final Logger logger = LoggerFactory.getLogger( DepmapBasedResolver.class ); - private final RepositoryConfigurator repositoryConfigurator; + @Requirement + private RepositoryConfigurator repositoryConfigurator; private Repository bisectRepo; - private final Repository systemRepo; + private Repository systemRepo; - private final DefaultDependencyMap depmap; + @Requirement + private DefaultDependencyMap depmap; private AtomicFileCounter bisectCounter; private static final RpmDb rpmdb = new RpmDb(); - @Inject - public DepmapBasedResolver( RepositoryConfigurator repositoryConfigurator, DefaultDependencyMap depmap ) + @Override + public void initialize() { - this.repositoryConfigurator = repositoryConfigurator; - this.depmap = depmap; - initializeBisect(); systemRepo = repositoryConfigurator.configureRepository( "resolve" ); diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/FlatRepositoryFactory.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/FlatRepositoryFactory.java index 7b9b87e..38ad43c 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/FlatRepositoryFactory.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/FlatRepositoryFactory.java @@ -18,8 +18,7 @@ package org.fedoraproject.xmvn.resolver.impl.depmap; import java.nio.file.Path; import java.util.List; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; import org.fedoraproject.xmvn.config.Stereotype; @@ -32,8 +31,7 @@ import org.fedoraproject.xmvn.config.Stereotype; * * @author Mikolaj Izdebski */ -@Named( "flat" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "flat" ) @Deprecated public class FlatRepositoryFactory extends SimpleRepositoryFactory diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/JppRepositoryFactory.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/JppRepositoryFactory.java index acf6920..b38cf47 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/JppRepositoryFactory.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/JppRepositoryFactory.java @@ -18,8 +18,7 @@ package org.fedoraproject.xmvn.resolver.impl.depmap; import java.nio.file.Path; import java.util.List; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; import org.fedoraproject.xmvn.config.Stereotype; @@ -32,8 +31,7 @@ import org.fedoraproject.xmvn.config.Stereotype; * * @author Mikolaj Izdebski */ -@Named( "jpp" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "jpp" ) @Deprecated public class JppRepositoryFactory extends SimpleRepositoryFactory diff --git a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/MavenRepositoryFactory.java b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/MavenRepositoryFactory.java index 43b53d2..38b08ee 100644 --- a/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/MavenRepositoryFactory.java +++ b/xmvn-core/src/main/java/org/fedoraproject/xmvn/resolver/impl/depmap/MavenRepositoryFactory.java @@ -18,8 +18,7 @@ package org.fedoraproject.xmvn.resolver.impl.depmap; import java.nio.file.Path; import java.util.List; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; import org.fedoraproject.xmvn.config.Stereotype; @@ -32,8 +31,7 @@ import org.fedoraproject.xmvn.config.Stereotype; * * @author Mikolaj Izdebski */ -@Named( "maven" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "maven" ) @Deprecated public class MavenRepositoryFactory extends SimpleRepositoryFactory diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/deployer/BasicDeployerTest.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/deployer/BasicDeployerTest.java index deaba2f..c6c75a6 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/deployer/BasicDeployerTest.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/deployer/BasicDeployerTest.java @@ -15,16 +15,14 @@ */ package org.fedoraproject.xmvn.deployer; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; /** * @author Mikolaj Izdebski */ public class BasicDeployerTest - extends InjectedTest + extends PlexusTestCase { /** * Test if Sisu can load deployer component. diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BasicResolverTest.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BasicResolverTest.java index 4f70c17..fb5a20a 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BasicResolverTest.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BasicResolverTest.java @@ -15,10 +15,7 @@ */ package org.fedoraproject.xmvn.resolver; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.DefaultArtifact; @@ -30,7 +27,7 @@ import org.fedoraproject.xmvn.config.ResolverSettings; * @author Mikolaj Izdebski */ public class BasicResolverTest - extends InjectedTest + extends PlexusTestCase { /** * Test if Plexus can load resolver component. diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BisectResolverTest.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BisectResolverTest.java index 698dc2d..a5a2466 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BisectResolverTest.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/BisectResolverTest.java @@ -15,17 +15,11 @@ */ package org.fedoraproject.xmvn.resolver; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.sisu.launch.InjectedTest; -import org.junit.After; -import org.junit.Before; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -39,11 +33,10 @@ import org.fedoraproject.xmvn.utils.AtomicFileCounter; * @author Michael Simacek */ public class BisectResolverTest - extends InjectedTest + extends PlexusTestCase { private AtomicFileCounter counter; - @Before @Override public void setUp() throws Exception @@ -56,7 +49,6 @@ public class BisectResolverTest counter = new AtomicFileCounter( counterPath.toString(), 1000 ); } - @After @Override public void tearDown() throws Exception diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/JavaHomeResolverTest.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/JavaHomeResolverTest.java index 779b925..2610a5a 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/JavaHomeResolverTest.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/JavaHomeResolverTest.java @@ -15,13 +15,9 @@ */ package org.fedoraproject.xmvn.resolver; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.nio.file.Files; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.DefaultArtifact; @@ -33,7 +29,7 @@ import org.fedoraproject.xmvn.utils.FileUtils; * @author Mikolaj Izdebski */ public class JavaHomeResolverTest - extends InjectedTest + extends PlexusTestCase { /** * Test if artifacts are resolved correctly from Java home. diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/TestConfigurator.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/TestConfigurator.java index d4502da..7a6163a 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/TestConfigurator.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/TestConfigurator.java @@ -15,29 +15,20 @@ */ package org.fedoraproject.xmvn.resolver; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; import org.fedoraproject.xmvn.config.Configuration; -import org.fedoraproject.xmvn.config.ConfigurationMerger; +import org.fedoraproject.xmvn.config.Configurator; import org.fedoraproject.xmvn.config.Repository; import org.fedoraproject.xmvn.config.impl.DefaultConfigurator; /** * @author Mikolaj Izdebski */ -@Named( "default" ) -@Singleton +@Component( role = Configurator.class ) public class TestConfigurator extends DefaultConfigurator { - @Inject - public TestConfigurator( ConfigurationMerger merger ) - { - super( merger ); - } - @Override public synchronized Configuration getConfiguration() { diff --git a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapTest.java b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapTest.java index dfa3045..8fcd5f5 100644 --- a/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapTest.java +++ b/xmvn-core/src/test/java/org/fedoraproject/xmvn/resolver/impl/depmap/DepmapTest.java @@ -15,9 +15,6 @@ */ package org.fedoraproject.xmvn.resolver.impl.depmap; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.Writer; import java.nio.charset.StandardCharsets; @@ -26,7 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -39,7 +36,7 @@ import org.fedoraproject.xmvn.config.ResolverSettings; */ @Deprecated public class DepmapTest - extends InjectedTest + extends PlexusTestCase { private DefaultDependencyMap readDepmap( Path fragment ) throws Exception diff --git a/xmvn-mojo/pom.xml b/xmvn-mojo/pom.xml index de1a32c..1b73871 100644 --- a/xmvn-mojo/pom.xml +++ b/xmvn-mojo/pom.xml @@ -64,12 +64,12 @@ xmvn-core - javax.inject - javax.inject + org.codehaus.plexus + plexus-component-annotations - org.eclipse.sisu - org.eclipse.sisu.inject + org.sonatype.sisu + sisu-inject-plexus org.sonatype.sisu diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/BuildDependencyExtractor.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/BuildDependencyExtractor.java index 6166237..ea327e2 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/BuildDependencyExtractor.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/BuildDependencyExtractor.java @@ -17,9 +17,8 @@ package org.fedoraproject.xmvn.dependency.impl; import java.io.IOException; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.fedoraproject.xmvn.dependency.DependencyExtractionRequest; import org.fedoraproject.xmvn.dependency.DependencyExtractionResult; @@ -35,19 +34,13 @@ import org.fedoraproject.xmvn.model.ModelProcessor; * * @author Mikolaj Izdebski */ -@Named( DependencyExtractor.BUILD ) -@Singleton +@Component( role = DependencyExtractor.class, hint = DependencyExtractor.BUILD ) public class BuildDependencyExtractor extends AbstractModelVisitor implements DependencyExtractor { - private final ModelProcessor modelProcessor; - - @Inject - public BuildDependencyExtractor( ModelProcessor modelProcessor ) - { - this.modelProcessor = modelProcessor; - } + @Requirement + private ModelProcessor modelProcessor; @Override public DependencyExtractionResult extract( DependencyExtractionRequest request ) diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/RuntimeDependencyExtractor.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/RuntimeDependencyExtractor.java index a50b285..b2ec52b 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/RuntimeDependencyExtractor.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/dependency/impl/RuntimeDependencyExtractor.java @@ -17,9 +17,8 @@ package org.fedoraproject.xmvn.dependency.impl; import java.io.IOException; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.fedoraproject.xmvn.dependency.DependencyExtractionRequest; import org.fedoraproject.xmvn.dependency.DependencyExtractionResult; @@ -35,19 +34,13 @@ import org.fedoraproject.xmvn.model.ModelProcessor; * * @author Mikolaj Izdebski */ -@Named( DependencyExtractor.RUNTIME ) -@Singleton +@Component( role = DependencyExtractor.class, hint = DependencyExtractor.RUNTIME ) public class RuntimeDependencyExtractor extends AbstractModelVisitor implements DependencyExtractor { - private final ModelProcessor modelProcessor; - - @Inject - public RuntimeDependencyExtractor( ModelProcessor modelProcessor ) - { - this.modelProcessor = modelProcessor; - } + @Requirement + private ModelProcessor modelProcessor; @Override public DependencyExtractionResult extract( DependencyExtractionRequest request ) diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelProcessor.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelProcessor.java index 682e9be..22420fb 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelProcessor.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelProcessor.java @@ -23,10 +23,6 @@ import java.util.ListIterator; import java.util.Map.Entry; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - import org.apache.maven.model.Activation; import org.apache.maven.model.ActivationFile; import org.apache.maven.model.ActivationOS; @@ -63,6 +59,8 @@ import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.Resource; import org.apache.maven.model.Scm; import org.apache.maven.model.Site; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.fedoraproject.xmvn.model.ModelFormatException; import org.fedoraproject.xmvn.model.ModelProcessor; @@ -76,18 +74,12 @@ import org.fedoraproject.xmvn.model.ModelVisitor; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = ModelProcessor.class ) public class DefaultModelProcessor implements ModelProcessor { - private final ModelReader modelReader; - - @Inject - public DefaultModelProcessor( ModelReader modelReader ) - { - this.modelReader = modelReader; - } + @Requirement + private ModelReader modelReader; @Override public void processModel( Path modelPath, ModelVisitor visitor ) diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelReader.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelReader.java index dd29214..159e5e3 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelReader.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/model/impl/DefaultModelReader.java @@ -21,11 +21,9 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import javax.inject.Named; -import javax.inject.Singleton; - import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.fedoraproject.xmvn.model.ModelFormatException; @@ -38,8 +36,7 @@ import org.fedoraproject.xmvn.model.ModelReader; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = ModelReader.class ) public class DefaultModelReader implements ModelReader { diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java index 618d5ca..226666c 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/BuilddepMojo.java @@ -27,12 +27,10 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; - import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -54,24 +52,17 @@ import org.fedoraproject.xmvn.resolver.Resolver; * @author Mikolaj Izdebski */ @Mojo( name = "builddep", aggregator = true, requiresDependencyResolution = ResolutionScope.NONE ) -@Named public class BuilddepMojo extends AbstractMojo { @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true ) private List reactorProjects; - private final Resolver resolver; - - private final DependencyExtractor buildDependencyExtractor; + @Component + private Resolver resolver; - @Inject - public BuilddepMojo( Resolver resolver, - @Named( DependencyExtractor.BUILD ) DependencyExtractor buildDependencyExtractor ) - { - this.resolver = resolver; - this.buildDependencyExtractor = buildDependencyExtractor; - } + @Component( hint = DependencyExtractor.BUILD ) + private DependencyExtractor buildDependencyExtractor; private static void addOptionalChild( Xpp3Dom parent, String tag, String value, String defaultValue ) { diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/InstallMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/InstallMojo.java index 8a8b8fb..b9bd24a 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/InstallMojo.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/InstallMojo.java @@ -25,22 +25,20 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; - import org.apache.maven.model.Dependency; import org.apache.maven.model.Exclusion; import org.apache.maven.model.Model; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.eclipse.aether.RepositorySystemSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonatype.aether.RepositorySystemSession; import org.fedoraproject.xmvn.artifact.Artifact; import org.fedoraproject.xmvn.artifact.DefaultArtifact; @@ -53,7 +51,6 @@ import org.fedoraproject.xmvn.utils.ArtifactUtils; * @author Mikolaj Izdebski */ @Mojo( name = "install", aggregator = true, requiresDependencyResolution = ResolutionScope.NONE ) -@Named public class InstallMojo extends AbstractMojo { @@ -82,17 +79,17 @@ public class InstallMojo @Parameter( readonly = true, defaultValue = "${repositorySystemSession}" ) private RepositorySystemSession repoSession; - private final Deployer deployer; + @Component + private Deployer deployer; - @Inject - public InstallMojo( Deployer deployer ) + void setReactorProjects( List reactorProjects ) { - this.deployer = deployer; + this.reactorProjects = reactorProjects; } - void setReactorProjects( List reactorProjects ) + public void setDeployer( Deployer deployer ) { - this.reactorProjects = reactorProjects; + this.deployer = deployer; } /** diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/Utils.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/Utils.java index 2f9e3c3..aa0dc46 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/Utils.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/Utils.java @@ -27,8 +27,8 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.codehaus.plexus.util.StringUtils; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.ArtifactType; +import org.sonatype.aether.RepositorySystemSession; +import org.sonatype.aether.artifact.ArtifactType; import org.fedoraproject.xmvn.artifact.Artifact; import org.fedoraproject.xmvn.artifact.DefaultArtifact; diff --git a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/AbstractDependencyTest.java b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/AbstractDependencyTest.java index 2c6039e..a4cd60a 100644 --- a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/AbstractDependencyTest.java +++ b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/AbstractDependencyTest.java @@ -15,16 +15,12 @@ */ package org.fedoraproject.xmvn.dependency; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - import java.nio.file.Path; import java.nio.file.Paths; import java.util.LinkedHashSet; import java.util.Set; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -34,7 +30,7 @@ import org.fedoraproject.xmvn.artifact.DefaultArtifact; * @author Mikolaj Izdebski */ public abstract class AbstractDependencyTest - extends InjectedTest + extends PlexusTestCase { private Path modelPath; diff --git a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/RuntimeDependencyExtractorTest.java b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/RuntimeDependencyExtractorTest.java index c7a0f75..4b69acb 100644 --- a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/RuntimeDependencyExtractorTest.java +++ b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/dependency/RuntimeDependencyExtractorTest.java @@ -15,16 +15,14 @@ */ package org.fedoraproject.xmvn.dependency; -import static org.junit.Assert.assertNotNull; - -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; /** * @author Mikolaj Izdebski */ public class RuntimeDependencyExtractorTest - extends InjectedTest + extends PlexusTestCase { /** * Test if Plexus can load runtime dependency extractor component. diff --git a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/DirectoryInstallationTest.java b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/DirectoryInstallationTest.java index 2475c38..2ecca76 100644 --- a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/DirectoryInstallationTest.java +++ b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/DirectoryInstallationTest.java @@ -71,7 +71,8 @@ public class DirectoryInstallationTest getProject().setArtifact( getArtifact() ); - InstallMojo mojo = new InstallMojo( deployer ); + InstallMojo mojo = new InstallMojo(); + mojo.setDeployer( deployer ); mojo.setReactorProjects( Collections.singletonList( getProject() ) ); mojo.execute(); diff --git a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/NullFileInstallationTest.java b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/NullFileInstallationTest.java index d61f8b4..b43ff81 100644 --- a/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/NullFileInstallationTest.java +++ b/xmvn-mojo/src/test/java/org/fedoraproject/xmvn/mojo/NullFileInstallationTest.java @@ -88,7 +88,8 @@ public class NullFileInstallationTest getProject().setArtifact( getArtifact() ); getProject().setFile( pomPath.toFile() ); - InstallMojo mojo = new InstallMojo( new DeployerMock() ); + InstallMojo mojo = new InstallMojo(); + mojo.setDeployer( new DeployerMock() ); mojo.setReactorProjects( Collections.singletonList( getProject() ) ); deployed = false; mojo.execute(); diff --git a/xmvn-parent/pom.xml b/xmvn-parent/pom.xml index 5f7544b..5f05b06 100644 --- a/xmvn-parent/pom.xml +++ b/xmvn-parent/pom.xml @@ -74,18 +74,18 @@ US-ASCII - 1.0.0.v20140518 + 1.13.1 5.0.3 - 1 2.3.0 1.35 - 3.2.4 - 18.0 + 3.1.3 + 13.0 2.1.1 - 3.2.3 + 3.0.5 3.0.20 + 1.5.5 3.3 - 0.2.0 + 2.3.0 1.7.7 @@ -141,23 +141,28 @@ ${mavenVersion} - org.eclipse.aether + org.sonatype.aether aether-api ${aetherVersion} + org.sonatype.aether + aether-util + ${aetherVersion} + + org.apache.maven.plugin-tools maven-plugin-annotations ${pluginToolsVersion} - javax.inject - javax.inject - ${atinjectVersion} + org.codehaus.plexus + plexus-component-annotations + ${plexusVersion} - org.eclipse.sisu - org.eclipse.sisu.inject + org.sonatype.sisu + sisu-inject-plexus ${sisuVersion} @@ -319,9 +324,9 @@ - org.eclipse.sisu - sisu-maven-plugin - ${sisuVersion} + org.codehaus.plexus + plexus-component-metadata + ${plexusVersion} org.codehaus.mojo @@ -433,19 +438,13 @@ - org.eclipse.sisu - sisu-maven-plugin + org.codehaus.plexus + plexus-component-metadata - process-classes - - main-index - - - - process-test-classes - test-index + generate-metadata + generate-test-metadata diff --git a/xmvn-tools/pom.xml b/xmvn-tools/pom.xml index 0a7fa5b..2ab7c00 100644 --- a/xmvn-tools/pom.xml +++ b/xmvn-tools/pom.xml @@ -48,8 +48,8 @@ xmvn-core - org.eclipse.sisu - org.eclipse.sisu.inject + org.sonatype.sisu + sisu-inject-plexus org.sonatype.sisu diff --git a/xmvn-tools/xmvn-bisect/pom.xml b/xmvn-tools/xmvn-bisect/pom.xml index 5d3c649..eab5b7d 100644 --- a/xmvn-tools/xmvn-bisect/pom.xml +++ b/xmvn-tools/xmvn-bisect/pom.xml @@ -33,8 +33,8 @@ - javax.inject - javax.inject + org.codehaus.plexus + plexus-component-annotations org.codehaus.plexus diff --git a/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/BisectCli.java b/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/BisectCli.java index 68c412b..8473ad2 100644 --- a/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/BisectCli.java +++ b/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/BisectCli.java @@ -17,17 +17,11 @@ package org.fedoraproject.xmvn.tools.bisect; import java.util.Map.Entry; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Module; import org.apache.maven.shared.invoker.InvocationRequest; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,20 +30,13 @@ import org.fedoraproject.xmvn.utils.AtomicFileCounter; /** * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = BisectCli.class ) public class BisectCli { private final Logger logger = LoggerFactory.getLogger( BisectCli.class ); - private final BuildExecutor buildExecutor; - - @Inject - public BisectCli( BuildExecutor buildExecutor ) - throws Exception - { - this.buildExecutor = buildExecutor; - } + @Requirement + private BuildExecutor buildExecutor; private static String getBuildLogName( int buildId ) { @@ -145,9 +132,8 @@ public class BisectCli { BisectCliRequest cliRequest = new BisectCliRequest( args ); - Module module = new WireModule( new SpaceModule( new URLClassSpace( BisectCli.class.getClassLoader() ) ) ); - Injector injector = Guice.createInjector( module ); - BisectCli cli = injector.getInstance( BisectCli.class ); + PlexusContainer container = new DefaultPlexusContainer(); + BisectCli cli = container.lookup( BisectCli.class ); cli.run( cliRequest ); } diff --git a/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/DefaultBuildExecutor.java b/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/DefaultBuildExecutor.java index 4214e86..0c80d87 100644 --- a/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/DefaultBuildExecutor.java +++ b/xmvn-tools/xmvn-bisect/src/main/java/org/fedoraproject/xmvn/tools/bisect/DefaultBuildExecutor.java @@ -19,18 +19,15 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; -import javax.inject.Named; -import javax.inject.Singleton; - import org.apache.maven.shared.invoker.DefaultInvoker; import org.apache.maven.shared.invoker.InvocationOutputHandler; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; +import org.codehaus.plexus.component.annotations.Component; -@Named -@Singleton +@Component( role = BuildExecutor.class ) public class DefaultBuildExecutor implements BuildExecutor { diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/CompoundRepositoryFactory.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/CompoundRepositoryFactory.java index 0beda6d..6cae0b5 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/CompoundRepositoryFactory.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/CompoundRepositoryFactory.java @@ -21,15 +21,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.fedoraproject.xmvn.repository.Repository; import org.fedoraproject.xmvn.repository.RepositoryConfigurator; +import org.fedoraproject.xmvn.repository.RepositoryFactory; /** * Factory creating compound repositories. @@ -40,18 +39,12 @@ import org.fedoraproject.xmvn.repository.RepositoryConfigurator; * * @author Mikolaj Izdebski */ -@Named( "compound" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "compound" ) public class CompoundRepositoryFactory extends AbstractRepositoryFactory { - private final RepositoryConfigurator configurator; - - @Inject - public CompoundRepositoryFactory( RepositoryConfigurator configurator ) - { - this.configurator = configurator; - } + @Requirement + private RepositoryConfigurator configurator; @Override public Repository getInstance( Xpp3Dom filter, Properties properties, Xpp3Dom configuration, String namespace ) diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/DefaultRepositoryConfigurator.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/DefaultRepositoryConfigurator.java index 640c2e6..41cf1bc 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/DefaultRepositoryConfigurator.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/DefaultRepositoryConfigurator.java @@ -18,10 +18,8 @@ package org.fedoraproject.xmvn.repository.impl; import java.util.Map; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.fedoraproject.xmvn.config.Configurator; @@ -36,21 +34,15 @@ import org.fedoraproject.xmvn.repository.RepositoryFactory; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = RepositoryConfigurator.class ) public class DefaultRepositoryConfigurator implements RepositoryConfigurator { - private final Configurator configurator; - - private final Map repositoryFactories; + @Requirement + private Configurator configurator; - @Inject - public DefaultRepositoryConfigurator( Configurator configurator, Map repositoryFactories ) - { - this.configurator = configurator; - this.repositoryFactories = repositoryFactories; - } + @Requirement + private Map repositoryFactories; private org.fedoraproject.xmvn.config.Repository findDescriptor( String repoId ) { diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/JppRepositoryFactory.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/JppRepositoryFactory.java index 4e7befb..002795c 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/JppRepositoryFactory.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/JppRepositoryFactory.java @@ -17,12 +17,11 @@ package org.fedoraproject.xmvn.repository.impl; import java.nio.file.Path; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.fedoraproject.xmvn.repository.Repository; +import org.fedoraproject.xmvn.repository.RepositoryFactory; /** * Factory creating JPP repositories. @@ -33,8 +32,7 @@ import org.fedoraproject.xmvn.repository.Repository; * * @author Mikolaj Izdebski */ -@Named( "jpp" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "jpp" ) public class JppRepositoryFactory extends SimpleRepositoryFactory { diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/MavenRepositoryFactory.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/MavenRepositoryFactory.java index d682563..e5a09e2 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/MavenRepositoryFactory.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/repository/impl/MavenRepositoryFactory.java @@ -17,12 +17,11 @@ package org.fedoraproject.xmvn.repository.impl; import java.nio.file.Path; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.fedoraproject.xmvn.repository.Repository; +import org.fedoraproject.xmvn.repository.RepositoryFactory; /** * Factory creating JPP repositories. @@ -33,8 +32,7 @@ import org.fedoraproject.xmvn.repository.Repository; * * @author Mikolaj Izdebski */ -@Named( "maven" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "maven" ) public class MavenRepositoryFactory extends SimpleRepositoryFactory { diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/cli/InstallerCli.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/cli/InstallerCli.java index ffecaaa..c78043a 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/cli/InstallerCli.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/cli/InstallerCli.java @@ -18,16 +18,10 @@ package org.fedoraproject.xmvn.tools.install.cli; import java.io.IOException; import java.nio.file.Paths; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,19 +32,13 @@ import org.fedoraproject.xmvn.tools.install.Installer; /** * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = InstallerCli.class ) public class InstallerCli { private final Logger logger = LoggerFactory.getLogger( InstallerCli.class ); - private final Installer installer; - - @Inject - public InstallerCli( Installer installer ) - { - this.installer = installer; - } + @Requirement + private Installer installer; private int run( InstallerCliRequest cliRequest ) { @@ -78,10 +66,8 @@ public class InstallerCli { InstallerCliRequest cliRequest = new InstallerCliRequest( args ); - Module module = - new WireModule( new SpaceModule( new URLClassSpace( InstallerCli.class.getClassLoader() ) ) ); - Injector injector = Guice.createInjector( module ); - InstallerCli cli = injector.getInstance( InstallerCli.class ); + PlexusContainer container = new DefaultPlexusContainer(); + InstallerCli cli = container.lookup( InstallerCli.class ); System.exit( cli.run( cliRequest ) ); } diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java index d8a2ac5..78c71f5 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java @@ -19,29 +19,23 @@ import java.util.Arrays; import java.util.Collection; import java.util.Properties; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.eclipse.sisu.Nullable; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.fedoraproject.xmvn.artifact.Artifact; import org.fedoraproject.xmvn.tools.install.ArtifactInstaller; -@Named -@Singleton +@Component( role = ArtifactInstallerFactory.class ) public class ArtifactInstallerFactory { private final Logger logger = LoggerFactory.getLogger( ArtifactInstallerFactory.class ); - @Inject + @Requirement private ArtifactInstaller defaultArtifactInstaller; - @Inject - @Nullable - @Named( "eclipse" ) + @Requirement( hint = "eclipse", optional = true ) private ArtifactInstaller eclipseArtifactInstaller; /** diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultArtifactInstaller.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultArtifactInstaller.java index 09d9e0d..a4e42c6 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultArtifactInstaller.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultArtifactInstaller.java @@ -30,10 +30,8 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,16 +51,20 @@ import org.fedoraproject.xmvn.tools.install.JavaPackage; import org.fedoraproject.xmvn.tools.install.RegularFile; import org.fedoraproject.xmvn.tools.install.SymbolicLink; -@Named -@Singleton +@Component( role = ArtifactInstaller.class ) public class DefaultArtifactInstaller implements ArtifactInstaller { private final Logger logger = LoggerFactory.getLogger( DefaultArtifactInstaller.class ); - @Inject + @Requirement private RepositoryConfigurator repositoryConfigurator; + public void setRepositoryConfigurator( RepositoryConfigurator repositoryConfigurator ) + { + this.repositoryConfigurator = repositoryConfigurator; + } + @Override public void install( JavaPackage targetPackage, ArtifactMetadata am, PackagingRule rule, String basePackageName ) throws ArtifactInstallationException diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultInstaller.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultInstaller.java index 6fdbf4c..5f627a5 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultInstaller.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/DefaultInstaller.java @@ -27,11 +27,10 @@ import java.util.List; import java.util.Map; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.xml.stream.XMLStreamException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,8 +57,7 @@ import org.fedoraproject.xmvn.tools.install.InstallationResult; import org.fedoraproject.xmvn.tools.install.Installer; import org.fedoraproject.xmvn.tools.install.JavaPackage; -@Named -@Singleton +@Component( role = Installer.class ) public class DefaultInstaller implements Installer { @@ -67,19 +65,34 @@ public class DefaultInstaller private final Set reactor = new LinkedHashSet<>(); - @Inject + @Requirement private Configurator configurator; - @Inject + @Requirement private Resolver resolver; - @Inject + @Requirement private ArtifactInstallerFactory installerFactory; private Configuration configuration; private PackageRegistry packageRegistry; + public void setConfigurator( Configurator configurator ) + { + this.configurator = configurator; + } + + public void setResolver( Resolver resolver ) + { + this.resolver = resolver; + } + + public void setInstallerFactory( ArtifactInstallerFactory installerFactory ) + { + this.installerFactory = installerFactory; + } + /** * Build initial reactor state from installation plan. * diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/CustomRepositoryTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/CustomRepositoryTest.java index 42d0e71..e19e59f 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/CustomRepositoryTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/CustomRepositoryTest.java @@ -15,10 +15,7 @@ */ package org.fedoraproject.xmvn.repository; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.config.Configuration; @@ -29,7 +26,7 @@ import org.fedoraproject.xmvn.config.Repository; * @author Mikolaj Izdebski */ public class CustomRepositoryTest - extends InjectedTest + extends PlexusTestCase { /** * Test if simple (non-composite) repository configuration works as expected. diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/DefaultConfigurator.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/DefaultConfigurator.java index e05850b..255af15 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/DefaultConfigurator.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/DefaultConfigurator.java @@ -15,9 +15,7 @@ */ package org.fedoraproject.xmvn.repository; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; import org.junit.Assert; import org.fedoraproject.xmvn.config.Configuration; @@ -26,8 +24,7 @@ import org.fedoraproject.xmvn.config.Configurator; /** * @author Mikolaj Izdebski */ -@Singleton -@Named( "default" ) +@Component( role = Configurator.class ) public class DefaultConfigurator implements Configurator { diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/JppRepositoryTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/JppRepositoryTest.java index ec0c9c6..0162040 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/JppRepositoryTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/JppRepositoryTest.java @@ -15,12 +15,9 @@ */ package org.fedoraproject.xmvn.repository; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import java.nio.file.Paths; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -33,7 +30,7 @@ import org.fedoraproject.xmvn.config.Repository; * @author Mikolaj Izdebski */ public class JppRepositoryTest - extends InjectedTest + extends PlexusTestCase { @Test public void testJppRepository() diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/LayoutTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/LayoutTest.java index 9535037..e443fe6 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/LayoutTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/LayoutTest.java @@ -15,16 +15,11 @@ */ package org.fedoraproject.xmvn.repository; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import java.nio.file.Path; import java.util.Properties; +import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.eclipse.sisu.launch.InjectedTest; -import org.junit.Before; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -34,13 +29,14 @@ import org.fedoraproject.xmvn.artifact.DefaultArtifact; * @author Mikolaj Izdebski */ public class LayoutTest - extends InjectedTest + extends PlexusTestCase { private Repository mavenRepository; private Repository jppRepository; private Repository getRepositoryInstance( String type ) + throws Exception { RepositoryFactory factory = lookup( RepositoryFactory.class, type ); assertNotNull( factory ); @@ -55,7 +51,6 @@ public class LayoutTest return repository; } - @Before @Override public void setUp() throws Exception diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MavenRepositoryTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MavenRepositoryTest.java index 70d2940..cb7c919 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MavenRepositoryTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MavenRepositoryTest.java @@ -15,13 +15,9 @@ */ package org.fedoraproject.xmvn.repository; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - import java.nio.file.Paths; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.artifact.Artifact; @@ -34,7 +30,7 @@ import org.fedoraproject.xmvn.config.Repository; * @author Mikolaj Izdebski */ public class MavenRepositoryTest - extends InjectedTest + extends PlexusTestCase { @Test public void testMavenRepository() diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MyRepositoryFactory.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MyRepositoryFactory.java index 86b3a4c..d3fc9ff 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MyRepositoryFactory.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/repository/MyRepositoryFactory.java @@ -22,16 +22,13 @@ import static org.junit.Assert.fail; import java.util.Properties; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.xml.Xpp3Dom; /** * @author Mikolaj Izdebski */ -@Named( "my-type" ) -@Singleton +@Component( role = RepositoryFactory.class, hint = "my-type" ) public class MyRepositoryFactory implements RepositoryFactory { diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/AbstractInstallerTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/AbstractInstallerTest.java index 2c9c603..3d1c1c8 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/AbstractInstallerTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/AbstractInstallerTest.java @@ -31,7 +31,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.eclipse.sisu.launch.InjectedTest; import org.junit.After; import org.junit.Before; @@ -39,7 +38,6 @@ import org.junit.Before; * @author Mikolaj Izdebski */ public abstract class AbstractInstallerTest - extends InjectedTest { protected Path workdir; diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/ArtifactInstallerTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/ArtifactInstallerTest.java index 6a6c26b..3ec6961 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/ArtifactInstallerTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/ArtifactInstallerTest.java @@ -19,9 +19,6 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.isA; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.nio.file.Files; import java.nio.file.Path; @@ -32,12 +29,10 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import javax.inject.Inject; - -import com.google.inject.Binder; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.component.annotations.Requirement; import org.easymock.EasyMockRunner; import org.easymock.Mock; -import org.eclipse.sisu.launch.InjectedTest; import org.junit.Test; import org.junit.runner.RunWith; @@ -49,24 +44,24 @@ import org.fedoraproject.xmvn.metadata.PackageMetadata; import org.fedoraproject.xmvn.repository.ArtifactContext; import org.fedoraproject.xmvn.repository.Repository; import org.fedoraproject.xmvn.repository.RepositoryConfigurator; +import org.fedoraproject.xmvn.tools.install.impl.DefaultArtifactInstaller; /** * @author Michael Simacek */ @RunWith( EasyMockRunner.class ) public class ArtifactInstallerTest - extends InjectedTest + extends PlexusTestCase { @Mock Repository repositoryMock; - @Inject - private ArtifactInstaller installer; + @Requirement + private RepositoryConfigurator repositoryConfigurator; - @Override - public void configure( Binder binder ) + private void configure( DefaultArtifactInstaller installer ) { - binder.bind( RepositoryConfigurator.class ).toInstance( new RepositoryConfigurator() + installer.setRepositoryConfigurator( new RepositoryConfigurator() { @Override public Repository configureRepository( String repoId ) @@ -93,6 +88,8 @@ public class ArtifactInstallerTest expect( repositoryMock.getNamespace() ).andReturn( "ns" ); replay( repositoryMock ); + DefaultArtifactInstaller installer = new DefaultArtifactInstaller(); + configure( installer ); installer.install( pkg, am, rule, "foo" ); verify( repositoryMock ); diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/InstallerTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/InstallerTest.java index 64e7944..8567bcf 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/InstallerTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/InstallerTest.java @@ -31,8 +31,6 @@ import java.nio.file.Paths; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; -import com.google.inject.Binder; -import com.google.inject.Provider; import org.easymock.EasyMockRunner; import org.easymock.Mock; import org.junit.Before; @@ -52,6 +50,8 @@ import org.fedoraproject.xmvn.metadata.ArtifactMetadata; import org.fedoraproject.xmvn.resolver.ResolutionRequest; import org.fedoraproject.xmvn.resolver.ResolutionResult; import org.fedoraproject.xmvn.resolver.Resolver; +import org.fedoraproject.xmvn.tools.install.impl.ArtifactInstallerFactory; +import org.fedoraproject.xmvn.tools.install.impl.DefaultInstaller; /** * @author Michael Simacek @@ -97,28 +97,21 @@ public class InstallerTest } } - @Override - public void configure( Binder binder ) + public void configure( DefaultInstaller installer ) { - binder.bind( Configurator.class ).toProvider( new Provider() - { - @Override - public Configurator get() - { - return configuratorMock; - } - } ); - - binder.bind( ArtifactInstaller.class ).toInstance( new MockArtifactInstaller() ); + installer.setConfigurator( configuratorMock ); - binder.bind( Resolver.class ).toProvider( new Provider() + installer.setInstallerFactory( new ArtifactInstallerFactory() { @Override - public Resolver get() + public ArtifactInstaller getInstallerFor( org.fedoraproject.xmvn.artifact.Artifact artifact, + java.util.Properties properties ) { - return resolverMock; + return new MockArtifactInstaller(); } } ); + + installer.setResolver( resolverMock ); } private void addResolution( String coordinates, final String compatVersion, final String namespace, final Path path ) @@ -177,7 +170,8 @@ public class InstallerTest request.setDescriptorRoot( descriptorRoot ); request.setInstallationPlan( prepareInstallationPlanFile( planName ) ); - Installer installer = lookup( Installer.class ); + DefaultInstaller installer = new DefaultInstaller(); + configure( installer ); assertNotNull( installer ); installer.install( request ); diff --git a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/impl/EffectivePackagingTest.java b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/impl/EffectivePackagingTest.java index 69d2cbf..ea27bef 100644 --- a/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/impl/EffectivePackagingTest.java +++ b/xmvn-tools/xmvn-install/src/test/java/org/fedoraproject/xmvn/tools/install/impl/EffectivePackagingTest.java @@ -15,14 +15,9 @@ */ package org.fedoraproject.xmvn.tools.install.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - import java.util.List; -import org.eclipse.sisu.launch.InjectedTest; +import org.codehaus.plexus.PlexusTestCase; import org.junit.Test; import org.fedoraproject.xmvn.config.Artifact; @@ -34,7 +29,7 @@ import org.fedoraproject.xmvn.config.PackagingRule; * @author Mikolaj Izdebski */ public class EffectivePackagingTest - extends InjectedTest + extends PlexusTestCase { /** * Test if multiple rules are correctly aggregated into single effective rule. diff --git a/xmvn-tools/xmvn-resolve/src/main/java/org/fedoraproject/xmvn/tools/resolve/ResolverCli.java b/xmvn-tools/xmvn-resolve/src/main/java/org/fedoraproject/xmvn/tools/resolve/ResolverCli.java index 3b77a57..7592b50 100644 --- a/xmvn-tools/xmvn-resolve/src/main/java/org/fedoraproject/xmvn/tools/resolve/ResolverCli.java +++ b/xmvn-tools/xmvn-resolve/src/main/java/org/fedoraproject/xmvn/tools/resolve/ResolverCli.java @@ -20,20 +20,15 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,19 +48,13 @@ import org.fedoraproject.xmvn.tools.resolve.xml.CompoundResult; * * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = ResolverCli.class ) public class ResolverCli { private final Logger logger = LoggerFactory.getLogger( ResolverCli.class ); - private final Resolver resolver; - - @Inject - public ResolverCli( Resolver resolver ) - { - this.resolver = resolver; - } + @Requirement + private Resolver resolver; private List parseRequests( ResolverCliRequest cli ) throws JAXBException @@ -165,9 +154,8 @@ public class ResolverCli { ResolverCliRequest cliRequest = new ResolverCliRequest( args ); - Module module = new WireModule( new SpaceModule( new URLClassSpace( ResolverCli.class.getClassLoader() ) ) ); - Injector injector = Guice.createInjector( module ); - ResolverCli cli = injector.getInstance( ResolverCli.class ); + PlexusContainer container = new DefaultPlexusContainer(); + ResolverCli cli = container.lookup( ResolverCli.class ); cli.run( cliRequest ); } diff --git a/xmvn-tools/xmvn-subst/pom.xml b/xmvn-tools/xmvn-subst/pom.xml index 7afdecb..336bcd2 100644 --- a/xmvn-tools/xmvn-subst/pom.xml +++ b/xmvn-tools/xmvn-subst/pom.xml @@ -33,8 +33,8 @@ - javax.inject - javax.inject + org.codehaus.plexus + plexus-component-annotations diff --git a/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/ArtifactVisitor.java b/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/ArtifactVisitor.java index e26399c..33ce7d9 100644 --- a/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/ArtifactVisitor.java +++ b/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/ArtifactVisitor.java @@ -25,10 +25,8 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,8 +36,7 @@ import org.fedoraproject.xmvn.resolver.Resolver; import org.fedoraproject.xmvn.utils.ArtifactUtils; import org.fedoraproject.xmvn.utils.FileUtils; -@Named -@Singleton +@Component( role = ArtifactVisitor.class ) public class ArtifactVisitor implements FileVisitor { @@ -47,7 +44,8 @@ public class ArtifactVisitor private final Set types = new LinkedHashSet<>(); - private final Resolver resolver; + @Requirement + private Resolver resolver; private boolean followSymlinks; @@ -55,12 +53,6 @@ public class ArtifactVisitor private int failureCount; - @Inject - public ArtifactVisitor( Resolver resolver ) - { - this.resolver = resolver; - } - public void setTypes( Collection types ) { this.types.addAll( types ); diff --git a/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/SubstCli.java b/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/SubstCli.java index fae1d90..2eb209c 100644 --- a/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/SubstCli.java +++ b/xmvn-tools/xmvn-subst/src/main/java/org/fedoraproject/xmvn/tools/subst/SubstCli.java @@ -19,35 +19,23 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Module; -import org.eclipse.sisu.space.SpaceModule; -import org.eclipse.sisu.space.URLClassSpace; -import org.eclipse.sisu.wire.WireModule; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Mikolaj Izdebski */ -@Named -@Singleton +@Component( role = SubstCli.class ) public class SubstCli { private final Logger logger = LoggerFactory.getLogger( SubstCli.class ); - private final ArtifactVisitor visitor; - - @Inject - public SubstCli( ArtifactVisitor visitor ) - { - this.visitor = visitor; - } + @Requirement + private ArtifactVisitor visitor; private void run( SubstCliRequest cliRequest ) { @@ -77,9 +65,8 @@ public class SubstCli { SubstCliRequest cliRequest = new SubstCliRequest( args ); - Module module = new WireModule( new SpaceModule( new URLClassSpace( SubstCli.class.getClassLoader() ) ) ); - Injector injector = Guice.createInjector( module ); - SubstCli cli = injector.getInstance( SubstCli.class ); + PlexusContainer container = new DefaultPlexusContainer(); + SubstCli cli = container.lookup( SubstCli.class ); cli.run( cliRequest ); } -- 2.1.0