Author: rfscholte
Date: Sat Mar 14 14:27:00 2015
New Revision: 1666687

URL: http://svn.apache.org/r1666687
Log:
migrate to M3.0.
Step 2: Switch to maven-artifact-transfer for ArtifactInstaller
 - Add MojoTestRepositorySystem so the testing-harness can create Artifacts
All junittests succeed, 2 types or IT failures: modelValidation and metadata 
checksums

Added:
    
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/
   (with props)
    
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/MojoTestRepositorySystem.java
    maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/   (with 
props)
    maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/  
 (with props)
    
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/components.xml
Modified:
    maven/plugins/branches/m-install-p-3.0/pom.xml
    
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
    
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
    
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
    
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
    
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java

Modified: maven/plugins/branches/m-install-p-3.0/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/pom.xml?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- maven/plugins/branches/m-install-p-3.0/pom.xml (original)
+++ maven/plugins/branches/m-install-p-3.0/pom.xml Sat Mar 14 14:27:00 2015
@@ -96,7 +96,12 @@ under the License.
       <artifactId>maven-compat</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-artifact-transfer</artifactId>
+      <version>0.0.1-SNAPSHOT</version>
+    </dependency>
+    
     <!-- dependencies to annotations -->
     <dependency>
       <groupId>org.apache.maven.plugin-tools</groupId>
@@ -111,6 +116,13 @@ under the License.
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>1.9.5</version>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>commons-codec</groupId>
       <artifactId>commons-codec</artifactId>
       <version>1.6</version>

Modified: 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
 (original)
+++ 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java
 Sat Mar 14 14:27:00 2015
@@ -25,13 +25,13 @@ import java.util.Collection;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.installer.ArtifactInstaller;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.shared.artifact.install.ArtifactInstaller;
 import org.apache.maven.shared.utils.io.FileUtils;
 
 /**

Modified: 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
 (original)
+++ 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallFileMojo.java
 Sat Mar 14 14:27:00 2015
@@ -27,8 +27,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
-import java.net.MalformedURLException;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.LinkedHashSet;
 import java.util.Map;
@@ -37,10 +37,9 @@ import java.util.jar.JarFile;
 import java.util.regex.Pattern;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.installer.ArtifactInstallationException;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+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;
@@ -50,9 +49,9 @@ import org.apache.maven.plugin.MojoFailu
 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.project.ProjectBuildingRequest;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.project.validation.ModelValidationResult;
-import org.apache.maven.project.validation.ModelValidator;
+import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
 import org.apache.maven.shared.utils.ReaderFactory;
 import org.apache.maven.shared.utils.WriterFactory;
 import org.apache.maven.shared.utils.io.IOUtil;
@@ -151,7 +150,9 @@ public class InstallFileMojo
      * layout.
      * 
      * @since 2.2
+     * @deprecated Maven 3.0 doesn't support legacy layout anymore 
      */
+    @Deprecated
     @Parameter( property = "repositoryLayout", defaultValue = "default", 
required = true )
     private String repositoryLayout;
 
@@ -170,12 +171,9 @@ public class InstallFileMojo
     @Parameter( property = "localRepositoryPath" )
     private File localRepositoryPath;
 
-    /**
-     * The component used to validate the user-supplied artifact coordinates.
-     */
-    @Component
-    private ModelValidator modelValidator;
-
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
+    
     /**
      * @see org.apache.maven.plugin.Mojo#execute()
      */
@@ -190,6 +188,8 @@ public class InstallFileMojo
             throw new MojoFailureException( message );
         }
 
+        ProjectBuildingRequest buildingRequest = 
session.getProjectBuildingRequest();
+        
         // 
----------------------------------------------------------------------
         // Override the default localRepository variable
         // 
----------------------------------------------------------------------
@@ -197,15 +197,11 @@ public class InstallFileMojo
         {
             try
             {
-                ArtifactRepositoryLayout layout = repositoryLayouts.get( 
repositoryLayout );
-                getLog().debug( "Layout: " + layout.getClass() );
-
-                // noinspection deprecation
-                localRepository =
-                    new DefaultArtifactRepository( localRepository.getId(), 
localRepositoryPath.toURL().toString(),
-                                                   layout );
+                buildingRequest = installer.setLocalRepositoryBasedir( 
buildingRequest, localRepositoryPath );
+                
+                getLog().debug( "localRepoPath: " + 
buildingRequest.getRepositorySession().getLocalRepository().getBasedir() );
             }
-            catch ( MalformedURLException e )
+            catch ( ArtifactInstallerException e )
             {
                 throw new MojoExecutionException( "MalformedURLException: " + 
e.getMessage(), e );
             }
@@ -293,8 +289,6 @@ public class InstallFileMojo
             }
         }
 
-        validateArtifactInformation();
-
         Artifact artifact =
             artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
version, packaging, classifier );
 
@@ -303,6 +297,7 @@ public class InstallFileMojo
             throw new MojoFailureException( "Cannot install artifact. "
                 + "Artifact is already in the local repository.\n\nFile in 
question is: " + file + "\n" );
         }
+        artifact.setFile( file );
 
         File generatedPomFile = null;
 
@@ -341,12 +336,13 @@ public class InstallFileMojo
         // we don't
         try
         {
-            installer.install( file, artifact, localRepository );
+//            installer.install( file, artifact, localRepository );
+            installer.install( buildingRequest, Collections.singletonList( 
artifact ) );
             installChecksums( artifact, createChecksum );
             addMetaDataFilesForArtifact( artifact, metadataFiles, 
createChecksum );
 
         }
-        catch ( ArtifactInstallationException e )
+        catch ( ArtifactInstallerException e )
         {
             throw new MojoExecutionException( "Error installing artifact '" + 
artifact.getDependencyConflictId()
                 + "': " + e.getMessage(), e );
@@ -363,14 +359,16 @@ public class InstallFileMojo
         if ( sources != null )
         {
             artifact = artifactFactory.createArtifactWithClassifier( groupId, 
artifactId, version, "jar", "sources" );
+            artifact.setFile( sources );
             try
             {
-                installer.install( sources, artifact, localRepository );
+//                installer.install( sources, artifact, localRepository );
+                installer.install( buildingRequest, Collections.singletonList( 
artifact ) );
                 installChecksums( artifact, createChecksum );
                 addMetaDataFilesForArtifact( artifact, metadataFiles, 
createChecksum );
 
             }
-            catch ( ArtifactInstallationException e )
+            catch ( ArtifactInstallerException e )
             {
                 throw new MojoExecutionException( "Error installing sources " 
+ sources + ": " + e.getMessage(), e );
             }
@@ -379,14 +377,16 @@ public class InstallFileMojo
         if ( javadoc != null )
         {
             artifact = artifactFactory.createArtifactWithClassifier( groupId, 
artifactId, version, "jar", "javadoc" );
+            artifact.setFile( javadoc );
             try
             {
-                installer.install( javadoc, artifact, localRepository );
+//                installer.install( javadoc, artifact, localRepository );
+                installer.install( buildingRequest, Collections.singletonList( 
artifact ) );                
                 installChecksums( artifact, createChecksum );
                 addMetaDataFilesForArtifact( artifact, metadataFiles, 
createChecksum );
 
             }
-            catch ( ArtifactInstallationException e )
+            catch ( ArtifactInstallerException e )
             {
                 throw new MojoExecutionException( "Error installing API docs " 
+ javadoc + ": " + e.getMessage(), e );
             }
@@ -464,25 +464,6 @@ public class InstallFileMojo
         }
     }
 
-    /**
-     * Validates the user-supplied artifact information.
-     * 
-     * @throws MojoExecutionException If any artifact coordinate is invalid.
-     */
-    private void validateArtifactInformation()
-        throws MojoExecutionException
-    {
-        Model model = generateModel();
-
-        ModelValidationResult result = modelValidator.validate( model );
-
-        if ( result.getMessageCount() > 0 )
-        {
-            throw new MojoExecutionException( "The artifact information is 
incomplete or not valid:\n"
-                + result.render( "  " ) );
-        }
-    }
-
     /**
      * Generates a minimal model from the user-supplied artifact information.
      * 

Modified: 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
 (original)
+++ 
maven/plugins/branches/m-install-p-3.0/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
 Sat Mar 14 14:27:00 2015
@@ -28,14 +28,16 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.installer.ArtifactInstallationException;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.artifact.ProjectArtifact;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
 
 /**
  * Installs the project's main artifact, and any other artifacts attached by 
other plugins in the lifecycle, to the
@@ -65,6 +67,9 @@ public class InstallMojo
 
     @Parameter( defaultValue = "${reactorProjects}", required = true, readonly 
= true )
     private List<MavenProject> reactorProjects;
+    
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
 
     /**
      * Whether every project should be installed during its own install-phase 
or at the end of the multimodule build. If
@@ -182,7 +187,9 @@ public class InstallMojo
 
             if ( isPomArtifact )
             {
-                installer.install( pomFile, artifact, localRepository );
+//                installer.install( pomFile, artifact, localRepository );
+                installer.install( session.getProjectBuildingRequest(),
+                                   Collections.<Artifact> singletonList( new 
ProjectArtifact( project ) ) );
                 installChecksums( artifact, createChecksum );
                 addMetaDataFilesForArtifact( artifact, metadataFiles, 
createChecksum );
             }
@@ -197,7 +204,8 @@ public class InstallMojo
                 // but not package). We are designing in a proper solution for 
Maven 2.1
                 if ( file != null && file.isFile() )
                 {
-                    installer.install( file, artifact, localRepository );
+//                    installer.install( file, artifact, localRepository );
+                    installer.install( session.getProjectBuildingRequest(), 
Collections.singletonList( artifact ) );
                     installChecksums( artifact, createChecksum );
                     addMetaDataFilesForArtifact( artifact, metadataFiles, 
createChecksum );
                 }
@@ -214,7 +222,8 @@ public class InstallMojo
                         pomArtifact.setRelease( true );
                     }
 
-                    installer.install( pomFile, pomArtifact, localRepository );
+//                    installer.install( pomFile, pomArtifact, localRepository 
);
+                    installer.install( session.getProjectBuildingRequest(), 
Collections.singletonList( pomArtifact ) );
                     installChecksums( pomArtifact, createChecksum );
                     addMetaDataFilesForArtifact( pomArtifact, metadataFiles, 
createChecksum );
                 }
@@ -229,14 +238,15 @@ public class InstallMojo
 
             for ( Artifact attached : attachedArtifacts )
             {
-                installer.install( attached.getFile(), attached, 
localRepository );
+//                installer.install( attached.getFile(), attached, 
localRepository );
+                installer.install( session.getProjectBuildingRequest(), 
Collections.singletonList( attached ) );
                 installChecksums( attached, createChecksum );
                 addMetaDataFilesForArtifact( attached, metadataFiles, 
createChecksum );
             }
 
             installChecksums( metadataFiles );
         }
-        catch ( ArtifactInstallationException e )
+        catch ( ArtifactInstallerException e )
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }

Modified: 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
 (original)
+++ 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallFileMojoTest.java
 Sat Mar 14 14:27:00 2015
@@ -19,6 +19,9 @@ package org.apache.maven.plugin.install;
  * under the License.
  */
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
@@ -26,10 +29,14 @@ import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.plugin.LegacySupport;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.utils.ReaderFactory;
 import org.apache.maven.shared.utils.io.FileUtils;
 import org.apache.maven.shared.utils.io.IOUtil;
 import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager;
 import org.sonatype.aether.util.DefaultRepositorySystemSession;
 
 import java.io.File;
@@ -64,10 +71,10 @@ public class InstallFileMojoTest
 
         FileUtils.deleteDirectory( new File( getBasedir() + "/" + LOCAL_REPO ) 
);
         
-        LegacySupport legacySupport = lookup( LegacySupport.class );
-        RepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        MavenExecutionRequest executionRequest = new 
DefaultMavenExecutionRequest();
-        legacySupport.setSession( new MavenSession( getContainer(), 
repositorySession, executionRequest, null ) );
+//        LegacySupport legacySupport = lookup( LegacySupport.class );
+//        RepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
+//        MavenExecutionRequest executionRequest = new 
DefaultMavenExecutionRequest();
+//        legacySupport.setSession( new MavenSession( getContainer(), 
repositorySession, executionRequest, null ) );
     }
 
     public void testInstallFileTestEnvironment()
@@ -76,6 +83,8 @@ public class InstallFileMojoTest
         File testPom = new File( getBasedir(), 
"target/test-classes/unit/install-file-basic-test/plugin-config.xml" );
 
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assertNotNull( mojo );
     }
@@ -88,6 +97,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -113,6 +124,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -140,6 +153,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -188,6 +203,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -219,6 +236,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -245,6 +264,8 @@ public class InstallFileMojoTest
         InstallFileMojo mojo = (InstallFileMojo) lookupMojo( "install-file", 
testPom );
 
         assertNotNull( mojo );
+        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         assignValuesForParameter( mojo );
 
@@ -303,4 +324,15 @@ public class InstallFileMojoTest
     {
         return parameter.replace( '.', '/' );
     }
+    
+    private MavenSession createMavenSession()
+    {
+        MavenSession session = mock( MavenSession.class );
+        DefaultRepositorySystemSession repositorySession  = new 
DefaultRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager( new 
EnhancedLocalRepositoryManager( new File( LOCAL_REPO )     ) );
+        ProjectBuildingRequest buildingRequest = new 
DefaultProjectBuildingRequest();
+        buildingRequest.setRepositorySession( repositorySession );
+        when( session.getProjectBuildingRequest() ).thenReturn( 
buildingRequest );
+        return session;
+    }
 }

Modified: 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java?rev=1666687&r1=1666686&r2=1666687&view=diff
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
 (original)
+++ 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/InstallMojoTest.java
 Sat Mar 14 14:27:00 2015
@@ -19,25 +19,27 @@ package org.apache.maven.plugin.install;
  * under the License.
  */
 
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.execution.DefaultMavenExecutionRequest;
-import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.LegacySupport;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.install.stubs.AttachedArtifactStub0;
 import org.apache.maven.plugin.install.stubs.InstallArtifactStub;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.utils.io.FileUtils;
-import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.impl.internal.EnhancedLocalRepositoryManager;
 import org.sonatype.aether.util.DefaultRepositorySystemSession;
 
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-
 /**
  * @author <a href="mailto:arami...@apache.org";>Allan Ramirez</a>
  */
@@ -59,10 +61,10 @@ public class InstallMojoTest
 
         FileUtils.deleteDirectory( new File( getBasedir() + "/" + LOCAL_REPO ) 
);
         
-        LegacySupport legacySupport = lookup( LegacySupport.class );
-        RepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        MavenExecutionRequest executionRequest = new 
DefaultMavenExecutionRequest();
-        legacySupport.setSession( new MavenSession( getContainer(), 
repositorySession, executionRequest, null ) );
+//        LegacySupport legacySupport = lookup( LegacySupport.class );
+//        RepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
+//        MavenExecutionRequest executionRequest = new 
DefaultMavenExecutionRequest();
+//        legacySupport.setSession( new MavenSession( getContainer(), 
repositorySession, executionRequest, null ) );
     }
 
     public void testInstallTestEnvironment()
@@ -88,9 +90,11 @@ public class InstallMojoTest
             + "maven-install-test-1.0-SNAPSHOT.jar" );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
         
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
-        
+        setVariableValueToObject( mojo, "session", createMavenSession() );
+
         artifact = (InstallArtifactStub) project.getArtifact();
 
         artifact.setFile( file );
@@ -120,8 +124,10 @@ public class InstallMojoTest
         assertNotNull( mojo );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
 
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         List attachedArtifacts = project.getAttachedArtifacts();
 
@@ -160,8 +166,10 @@ public class InstallMojoTest
             + "maven-install-test-1.0-SNAPSHOT.jar" );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
-        
+        updateMavenProject( project );
+
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         artifact = (InstallArtifactStub) project.getArtifact();
 
@@ -184,8 +192,10 @@ public class InstallMojoTest
         assertNotNull( mojo );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
 
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         artifact = (InstallArtifactStub) project.getArtifact();
 
@@ -218,8 +228,10 @@ public class InstallMojoTest
         assertNotNull( mojo );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
 
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         String packaging = project.getPackaging();
 
@@ -232,7 +244,7 @@ public class InstallMojoTest
         String groupId = dotToSlashReplacer( artifact.getGroupId() );
 
         File installedArtifact = new File( getBasedir(), LOCAL_REPO + groupId 
+ "/" + artifact.getArtifactId() + "/" +
-            artifact.getVersion() + "/" + artifact.getArtifactId() + "-" + 
artifact.getVersion() + "." + "jar" );
+            artifact.getVersion() + "/" + artifact.getArtifactId() + "-" + 
artifact.getVersion() + "." + "pom" );
 
         assertTrue( installedArtifact.exists() );
         
@@ -251,8 +263,10 @@ public class InstallMojoTest
         File file = new File( getBasedir(), 
"target/test-classes/unit/basic-install-checksum/" + "maven-test-jar.jar" );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
 
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         artifact = (InstallArtifactStub) project.getArtifact();
 
@@ -338,8 +352,10 @@ public class InstallMojoTest
             + "maven-install-test-1.0-SNAPSHOT.jar" );
 
         MavenProject project = (MavenProject) getVariableValueFromObject( 
mojo, "project" );
+        updateMavenProject( project );
 
         setVariableValueToObject( mojo, "reactorProjects", 
Collections.singletonList( project ) );
+        setVariableValueToObject( mojo, "session", createMavenSession() );
 
         artifact = (InstallArtifactStub) project.getArtifact();
 
@@ -366,4 +382,22 @@ public class InstallMojoTest
     {
         return parameter.replace( '.', '/' );
     }
+    
+    private MavenSession createMavenSession()
+    {
+        MavenSession session = mock( MavenSession.class );
+        DefaultRepositorySystemSession repositorySession  = new 
DefaultRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager( new 
EnhancedLocalRepositoryManager( new File( LOCAL_REPO )     ) );
+        ProjectBuildingRequest buildingRequest = new 
DefaultProjectBuildingRequest();
+        buildingRequest.setRepositorySession( repositorySession );
+        when( session.getProjectBuildingRequest() ).thenReturn( 
buildingRequest );
+        return session;
+    }
+    
+    private void updateMavenProject( MavenProject project )
+    {
+       project.setGroupId( project.getArtifact().getGroupId() );
+       project.setArtifactId( project.getArtifact().getArtifactId() );
+       project.setVersion( project.getArtifact().getVersion() );
+    }
 }

Propchange: 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Mar 14 14:27:00 2015
@@ -0,0 +1 @@
+MINSTALL-\d+

Propchange: 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/MojoTestRepositorySystem.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/MojoTestRepositorySystem.java?rev=1666687&view=auto
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/MojoTestRepositorySystem.java
 (added)
+++ 
maven/plugins/branches/m-install-p-3.0/src/test/java/org/apache/maven/plugin/install/testingharness/MojoTestRepositorySystem.java
 Sat Mar 14 14:27:00 2015
@@ -0,0 +1,185 @@
+package org.apache.maven.plugin.install.testingharness;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.Repository;
+import org.apache.maven.repository.ArtifactTransferListener;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Proxy;
+import org.apache.maven.settings.Server;
+import org.sonatype.aether.RepositorySystemSession;
+
+public class MojoTestRepositorySystem implements RepositorySystem
+{
+
+    @Override
+    public Artifact createProjectArtifact( String groupId, String artifactId, 
String version )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Artifact createArtifact( String groupId, String artifactId, String 
version, String packaging )
+    {
+        // called in 
org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp()
+        return new DefaultArtifact( groupId, artifactId, version, "compile", 
packaging, "", null );
+    }
+
+    @Override
+    public Artifact createArtifact( String groupId, String artifactId, String 
version, String scope, String type )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    @Override
+    public Artifact createArtifactWithClassifier( String groupId, String 
artifactId, String version, String type,
+                                                  String classifier )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Artifact createPluginArtifact( Plugin plugin )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Artifact createDependencyArtifact( Dependency dependency )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactRepository buildArtifactRepository( Repository repository )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactRepository createDefaultRemoteRepository()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactRepository createDefaultLocalRepository()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactRepository createLocalRepository( File localRepository )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactRepository createArtifactRepository( String id, String url,
+                                                        
ArtifactRepositoryLayout repositoryLayout,
+                                                        
ArtifactRepositoryPolicy snapshots,
+                                                        
ArtifactRepositoryPolicy releases )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public List<ArtifactRepository> getEffectiveRepositories( 
List<ArtifactRepository> repositories )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Mirror getMirror( ArtifactRepository repository, List<Mirror> 
mirrors )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectMirror( List<ArtifactRepository> repositories, 
List<Mirror> mirrors )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectProxy( List<ArtifactRepository> repositories, 
List<Proxy> proxies )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectAuthentication( List<ArtifactRepository> repositories, 
List<Server> servers )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectMirror( RepositorySystemSession session, 
List<ArtifactRepository> repositories )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectProxy( RepositorySystemSession session, 
List<ArtifactRepository> repositories )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void injectAuthentication( RepositorySystemSession session, 
List<ArtifactRepository> repositories )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ArtifactResolutionResult resolve( ArtifactResolutionRequest request 
)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void publish( ArtifactRepository repository, File source, String 
remotePath,
+                         ArtifactTransferListener transferListener )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void retrieve( ArtifactRepository repository, File destination, 
String remotePath,
+                          ArtifactTransferListener transferListener )
+    {
+        throw new UnsupportedOperationException();
+    }
+
+}

Propchange: maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Mar 14 14:27:00 2015
@@ -0,0 +1 @@
+MINSTALL-\d+

Propchange: maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Propchange: 
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sat Mar 14 14:27:00 2015
@@ -0,0 +1 @@
+MINSTALL-\d+

Propchange: 
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/
------------------------------------------------------------------------------
    bugtraq:url = http://jira.codehaus.org/browse/%BUGID%

Added: 
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/components.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/components.xml?rev=1666687&view=auto
==============================================================================
--- 
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/components.xml
 (added)
+++ 
maven/plugins/branches/m-install-p-3.0/src/test/resources/META-INF/plexus/components.xml
 Sat Mar 14 14:27:00 2015
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<component-set>
+  <components>
+    <component>
+      <role>org.apache.maven.repository.RepositorySystem</role>
+      <role-hint>default</role-hint>
+      
<implementation>org.apache.maven.plugin.install.testingharness.MojoTestRepositorySystem</implementation>
+      <isolated-realm>false</isolated-realm>
+    </component>
+  </components>
+</component-set>


Reply via email to