Author: ifedorenko Date: Wed Oct 19 02:43:50 2011 New Revision: 1185951 URL: http://svn.apache.org/viewvc?rev=1185951&view=rev Log: Update to use maven 3.0 and other improvements
Made necessary changes to update maven version from 3.0-alpha-4 to 3.0. Replaced @plexus.component javadoc with corresponding @Component annotations, so I can work on the code inside m2e. Introduced AbstractMojoTestCase.setupContainerConfiguration, which allows plexus container customization by subclasses. Specific usecase was to enable JSR330 support, but should be useful in other cases. Introduced AbstractMojoTestCase.lookupConfiguredMojo. which returns fully configured Mojo instance. Unlike other lookupMojo methods, lookupConfiguredMojo uses maven plugin parameter default values, so test can use much smaller and easier to maintain pom.xml files. Introduced AbstractMojoTestCase newMavenSession and newMojoExecution helper methods. These helpers are used by lookupConfiguredMojo but should be useful in other cases. Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/pom.xml maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/pom.xml maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java maven/plugin-testing/branches/plugin-testing-mvn-3.x/pom.xml Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/pom.xml URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/pom.xml?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/pom.xml (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/pom.xml Wed Oct 19 02:43:50 2011 @@ -56,6 +56,10 @@ under the License. <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-aether-provider</artifactId> + </dependency> <!-- plexus --> <dependency> Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java Wed Oct 19 02:43:50 2011 @@ -26,14 +26,30 @@ import java.io.InputStream; import java.io.Reader; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.execution.MavenExecutionResult; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.lifecycle.internal.MojoDescriptorCreator; +import org.apache.maven.model.Plugin; import org.apache.maven.monitor.logging.DefaultLog; import org.apache.maven.plugin.Mojo; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.PluginParameterExpressionEvaluator; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.Parameter; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; @@ -41,6 +57,7 @@ import org.codehaus.plexus.PlexusContain import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurator; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.component.repository.ComponentDescriptor; @@ -50,6 +67,7 @@ import org.codehaus.plexus.logging.Logge import org.codehaus.plexus.util.InterpolationFilterReader; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.ReflectionUtils; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; @@ -73,6 +91,8 @@ public abstract class AbstractMojoTestCa private ComponentConfigurator configurator; private PlexusContainer container; + + private Map<String, MojoDescriptor> mojoDescriptors; /* * for the harness I think we have decided against going the route of using the maven project builder. @@ -95,10 +115,24 @@ public abstract class AbstractMojoTestCa PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader ); + Artifact artifact = + lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(), + pluginDescriptor.getArtifactId(), + pluginDescriptor.getVersion(), ".jar" ); + artifact.setFile( new File( getBasedir() ).getCanonicalFile() ); + pluginDescriptor.setPluginArtifact( artifact ); + pluginDescriptor.setArtifacts( Arrays.asList( artifact ) ); + for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() ) { getContainer().addComponentDescriptor( desc ); } + + mojoDescriptors = new HashMap<String, MojoDescriptor>(); + for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() ) + { + mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor ); + } } protected InputStream getPublicDescriptorStream() @@ -119,10 +153,7 @@ public abstract class AbstractMojoTestCa protected void setupContainer() { - ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); - - ContainerConfiguration cc = - new DefaultContainerConfiguration().setClassWorld( classWorld ).setName( "embedder" ); + ContainerConfiguration cc = setupContainerConfiguration(); try { container = new DefaultPlexusContainer( cc ); @@ -133,6 +164,13 @@ public abstract class AbstractMojoTestCa fail( "Failed to create plexus container." ); } } + + protected ContainerConfiguration setupContainerConfiguration() + { + ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); + + return new DefaultContainerConfiguration().setClassWorld( classWorld ).setName( "embedder" ); + } protected PlexusContainer getContainer() { @@ -272,6 +310,109 @@ public abstract class AbstractMojoTestCa return mojo; } + protected Mojo lookupConfiguredMojo( MavenProject project, String goal ) + throws Exception + { + return lookupConfiguredMojo( newMavenSession( project ), newMojoExecution( goal ) ); + } + + protected Mojo lookupConfiguredMojo( MavenSession session, MojoExecution execution ) + throws Exception, ComponentConfigurationException + { + MavenProject project = session.getCurrentProject(); + MojoDescriptor mojoDescriptor = execution.getMojoDescriptor(); + + Mojo mojo = (Mojo) lookup( mojoDescriptor.getRole(), mojoDescriptor.getRoleHint() ); + + ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator( session, execution ); + + Xpp3Dom configuration = null; + Plugin plugin = project.getPlugin( mojoDescriptor.getPluginDescriptor().getPluginLookupKey() ); + if ( plugin != null ) + { + configuration = (Xpp3Dom) plugin.getConfiguration(); + } + if ( configuration == null ) + { + configuration = new Xpp3Dom( "configuration" ); + } + configuration = Xpp3Dom.mergeXpp3Dom( execution.getConfiguration(), configuration ); + + PlexusConfiguration pluginConfiguration = new XmlPlexusConfiguration( configuration ); + + configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() ); + + return mojo; + } + + protected MavenSession newMavenSession( MavenProject project ) + { + MavenExecutionRequest request = new DefaultMavenExecutionRequest(); + MavenExecutionResult result = new DefaultMavenExecutionResult(); + + MavenSession session = new MavenSession( container, new MavenRepositorySystemSession(), request, result ); + session.setCurrentProject( project ); + session.setProjects( Arrays.asList( project ) ); + return session; + } + + protected MojoExecution newMojoExecution( String goal ) + { + MojoDescriptor mojoDescriptor = mojoDescriptors.get( goal ); + assertNotNull( mojoDescriptor ); + MojoExecution execution = new MojoExecution( mojoDescriptor ); + finalizeMojoConfiguration( execution ); + return execution; + } + + // copy&paste from org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.finalizeMojoConfiguration(MojoExecution) + private void finalizeMojoConfiguration( MojoExecution mojoExecution ) + { + MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); + + Xpp3Dom executionConfiguration = mojoExecution.getConfiguration(); + if ( executionConfiguration == null ) + { + executionConfiguration = new Xpp3Dom( "configuration" ); + } + + Xpp3Dom defaultConfiguration = MojoDescriptorCreator.convert( mojoDescriptor );; + + Xpp3Dom finalConfiguration = new Xpp3Dom( "configuration" ); + + if ( mojoDescriptor.getParameters() != null ) + { + for ( Parameter parameter : mojoDescriptor.getParameters() ) + { + Xpp3Dom parameterConfiguration = executionConfiguration.getChild( parameter.getName() ); + + if ( parameterConfiguration == null ) + { + parameterConfiguration = executionConfiguration.getChild( parameter.getAlias() ); + } + + Xpp3Dom parameterDefaults = defaultConfiguration.getChild( parameter.getName() ); + + parameterConfiguration = Xpp3Dom.mergeXpp3Dom( parameterConfiguration, parameterDefaults, Boolean.TRUE ); + + if ( parameterConfiguration != null ) + { + parameterConfiguration = new Xpp3Dom( parameterConfiguration, parameter.getName() ); + + if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) + && StringUtils.isNotEmpty( parameter.getImplementation() ) ) + { + parameterConfiguration.setAttribute( "implementation", parameter.getImplementation() ); + } + + finalConfiguration.addChild( parameterConfiguration ); + } + } + } + + mojoExecution.setConfiguration( finalConfiguration ); + } + /** * @param artifactId * @param pom Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/stubs/StubArtifactRepository.java Wed Oct 19 02:43:50 2011 @@ -232,4 +232,9 @@ public class StubArtifactRepository return Collections.emptyList(); } + public boolean isProjectAware() + { + return false; + } + } Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/pom.xml URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/pom.xml?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/pom.xml (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/pom.xml Wed Oct 19 02:43:50 2011 @@ -40,10 +40,6 @@ under the License. <dependencies> <dependency> <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> </dependency> <dependency> @@ -59,6 +55,10 @@ under the License. <artifactId>maven-compat</artifactId> </dependency> <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-aether-provider</artifactId> + </dependency> + <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-invoker</artifactId> <version>2.0.10</version> @@ -66,7 +66,7 @@ under the License. <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-test-tools</artifactId> - <version>2.0-SNAPSHOT</version> + <version>${project.version}</version> <scope>test</scope> </dependency> <dependency> Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/BuildTool.java Wed Oct 19 02:43:50 2011 @@ -32,6 +32,7 @@ import org.apache.maven.shared.invoker.I 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; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Disposable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; @@ -41,10 +42,10 @@ import org.codehaus.plexus.util.cli.Comm /** * Test-tool used to execute Maven builds in order to test plugin functionality. * - * @plexus.component role="org.apache.maven.shared.test.plugin.BuildTool" role-hint="default" * @author jdcasey * @version $Id$ */ +@Component(role=BuildTool.class) public class BuildTool implements Initializable, Disposable { Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ComponentTestTool.java Wed Oct 19 02:43:50 2011 @@ -20,6 +20,8 @@ package org.apache.maven.shared.test.plu */ import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import java.io.File; @@ -39,23 +41,19 @@ import java.io.IOException; * component's ancestor POMs cannot be resolved. * </p> * - * @plexus.component role="org.apache.maven.shared.test.plugin.ComponentTestTool" role-hint="default" * @author jdcasey * @version $Id$ */ +@Component( role = ComponentTestTool.class ) public class ComponentTestTool { /** Plexus role */ public static final String ROLE = ComponentTestTool.class.getName(); - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private ProjectTool projectTool; - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private RepositoryTool repositoryTool; /** Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/PluginTestTool.java Wed Oct 19 02:43:50 2011 @@ -20,6 +20,8 @@ package org.apache.maven.shared.test.plu */ import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import java.io.File; @@ -39,23 +41,19 @@ import java.io.IOException; * plugin's ancestor POMs cannot be resolved. * </p> * - * @plexus.component role="org.apache.maven.shared.test.plugin.PluginTestTool" role-hint="default" * @author jdcasey * @version $Id$ */ +@Component( role = PluginTestTool.class ) public class PluginTestTool { /** Plexus role */ public static final String ROLE = PluginTestTool.class.getName(); - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private ProjectTool projectTool; - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private RepositoryTool repositoryTool; /** Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/ProjectTool.java Wed Oct 19 02:43:50 2011 @@ -50,6 +50,9 @@ import org.apache.maven.project.ProjectB import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.project.artifact.ProjectArtifactMetadata; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; @@ -62,10 +65,10 @@ import org.codehaus.plexus.util.xml.pull * files (package phase of the normal build process) for distribution to a test local repository * directory. * - * @plexus.component role="org.apache.maven.shared.test.plugin.ProjectTool" role-hint="default" * @author jdcasey * @version $Id$ */ +@Component( role = ProjectTool.class ) public class ProjectTool { /** Plexus role */ @@ -73,34 +76,22 @@ public class ProjectTool public static final String INTEGRATION_TEST_DEPLOYMENT_REPO_URL = "integration-test.deployment.repo.url"; - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private BuildTool buildTool; - /** - * @plexus.requirement role-hint="default" - */ + @Requirement private RepositoryTool repositoryTool; - /** - * @plexus.requirement - */ + @Requirement private ProjectBuilder projectBuilder; - /** - * @plexus.requirement - */ + @Requirement private ArtifactHandlerManager artifactHandlerManager; - /** - * @plexus.requirement - */ + @Requirement private ArtifactFactory artifactFactory; - /** - * @plexus.requirement - */ + @Requirement private ArtifactRepositoryFactory artifactRepositoryFactory; /** @@ -250,6 +241,7 @@ public class ProjectTool { ProjectBuildingRequest request = new DefaultProjectBuildingRequest(); request.setLocalRepository( artifactRepositoryFactory.createArtifactRepository( "local", new File( "target/localrepo" ).getCanonicalFile().toURL().toExternalForm(), "default", null, null ) ); + request.setRepositorySession( new MavenRepositorySystemSession() ); MavenProject project = projectBuilder.build( pomInfo.getPomFile(), request ).getProject(); Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-tools/src/main/java/org/apache/maven/shared/test/plugin/RepositoryTool.java Wed Oct 19 02:43:50 2011 @@ -32,15 +32,21 @@ import org.apache.maven.artifact.reposit import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.execution.DefaultMavenExecutionRequest; +import org.apache.maven.execution.DefaultMavenExecutionResult; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifactMetadata; +import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.apache.maven.settings.MavenSettingsBuilder; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; +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.context.Context; import org.codehaus.plexus.context.ContextException; @@ -61,36 +67,31 @@ import org.codehaus.plexus.util.xml.pull * plugin's ancestor POMs cannot be resolved. * </p> * - * @plexus.component role="org.apache.maven.shared.test.plugin.RepositoryTool" role-hint="default" * @author jdcasey * @version $Id$ */ +@Component( role = RepositoryTool.class ) public class RepositoryTool implements Contextualizable { /** Plexus role */ public static final String ROLE = RepositoryTool.class.getName(); - /** - * @plexus.requirement - */ + @Requirement private ArtifactRepositoryFactory repositoryFactory; - /** - * @plexus.requirement - */ + @Requirement private MavenSettingsBuilder settingsBuilder; - /** - * @plexus.requirement - */ + @Requirement private ArtifactFactory artifactFactory; - /** - * @plexus.requirement - */ + @Requirement private ArtifactInstaller artifactInstaller; + @Requirement + private LegacySupport legacySupport; + // contextualized. private PlexusContainer container; @@ -217,6 +218,9 @@ public class RepositoryTool destination.getParentFile().mkdirs(); } + legacySupport.setSession( new MavenSession( container, new MavenRepositorySystemSession(), + new DefaultMavenExecutionRequest(), + new DefaultMavenExecutionResult() ) ); try { artifactInstaller.install( artifact.getFile(), artifact, localRepository ); @@ -226,6 +230,10 @@ public class RepositoryTool throw new TestToolsException( "Error installing plugin artifact to target local repository: " + targetLocalRepoBasedir, e ); } + finally + { + legacySupport.setSession( null ); + } installLocallyReachableAncestorPoms( realPomFile, localRepository ); } Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/pom.xml URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/pom.xml?rev=1185951&r1=1185950&r2=1185951&view=diff ============================================================================== --- maven/plugin-testing/branches/plugin-testing-mvn-3.x/pom.xml (original) +++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/pom.xml Wed Oct 19 02:43:50 2011 @@ -140,7 +140,7 @@ under the License. </distributionManagement> <properties> - <mavenVersion>3.0-alpha-4</mavenVersion> + <mavenVersion>3.0</mavenVersion> <plexusVersion>1.5.1</plexusVersion> </properties> @@ -168,12 +168,10 @@ under the License. <artifactId>maven-plugin-api</artifactId> <version>${mavenVersion}</version> </dependency> - - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-container-default</artifactId> - <version>${plexusVersion}</version> + <groupId>org.apache.maven</groupId> + <artifactId>maven-aether-provider</artifactId> + <version>${mavenVersion}</version> </dependency> <dependency>