maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1721728 - in /maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install: ./ internal/
Date Sat, 26 Dec 2015 12:44:09 GMT
Author: rfscholte
Date: Sat Dec 26 12:44:09 2015
New Revision: 1721728

URL: http://svn.apache.org/viewvc?rev=1721728&view=rev
Log:
Add optional argument for localRepository

Modified:
    maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
    maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
    maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstaller.java
    maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java

Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java?rev=1721728&r1=1721727&r2=1721728&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
(original)
+++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/ArtifactInstaller.java
Sat Dec 26 12:44:09 2015
@@ -19,6 +19,7 @@ package org.apache.maven.shared.artifact
  * under the License.
  */
 
+import java.io.File;
 import java.util.Collection;
 
 import org.apache.maven.artifact.Artifact;
@@ -37,4 +38,8 @@ public interface ArtifactInstaller
      */
     void install( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts
)
         throws ArtifactInstallerException;
+    
+    void install( ProjectBuildingRequest request, File localRepository, Collection<Artifact>
mavenArtifacts )
+                    throws ArtifactInstallerException;
+    
 }

Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java?rev=1721728&r1=1721727&r2=1721728&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
(original)
+++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/DefaultArtifactInstaller.java
Sat Dec 26 12:44:09 2015
@@ -19,6 +19,7 @@ package org.apache.maven.shared.artifact
  * under the License.
  */
 
+import java.io.File;
 import java.util.Collection;
 
 import org.apache.maven.artifact.Artifact;
@@ -43,7 +44,7 @@ public class DefaultArtifactInstaller
 
     private PlexusContainer container;
 
-    /** {@inheritDoc} */
+    @Override
     public void install( ProjectBuildingRequest request, Collection<Artifact> mavenArtifacts
)
         throws ArtifactInstallerException
     {
@@ -57,6 +58,24 @@ public class DefaultArtifactInstaller
         }
         catch ( ComponentLookupException e )
         {
+            throw new ArtifactInstallerException( e.getMessage(), e );
+        }
+    }
+    
+    @Override
+    public void install( ProjectBuildingRequest request, File localRepositry, Collection<Artifact>
mavenArtifacts )
+        throws ArtifactInstallerException
+    {
+        try
+        {
+            String hint = isMaven31() ? "maven31" : "maven3";
+
+            ArtifactInstaller effectiveArtifactInstaller = container.lookup( ArtifactInstaller.class,
hint );
+
+            effectiveArtifactInstaller.install( request, localRepositry, mavenArtifacts );
+        }
+        catch ( ComponentLookupException e )
+        {
             throw new ArtifactInstallerException( e.getMessage(), e );
         }
     }

Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstaller.java?rev=1721728&r1=1721727&r2=1721728&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstaller.java
(original)
+++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven30ArtifactInstaller.java
Sat Dec 26 12:44:09 2015
@@ -19,6 +19,7 @@ package org.apache.maven.shared.artifact
  * under the License.
  */
 
+import java.io.File;
 import java.util.Collection;
 
 import org.apache.maven.RepositoryUtils;
@@ -28,6 +29,7 @@ import org.apache.maven.project.ProjectB
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.shared.artifact.install.ArtifactInstaller;
 import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.artifact.repository.RepositoryManager;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.sonatype.aether.RepositorySystem;
@@ -46,13 +48,24 @@ public class Maven30ArtifactInstaller
 {
     @Requirement
     private RepositorySystem repositorySystem;
+    
+    @Requirement
+    private RepositoryManager repositoryManager; 
 
-    /** {@inheritDoc} */
+    @Override
     public void install( ProjectBuildingRequest buildingRequest,
                          Collection<org.apache.maven.artifact.Artifact> mavenArtifacts
)
                              throws ArtifactInstallerException
     {
-        // prepare installRequest
+        install( buildingRequest, null, mavenArtifacts );
+    }
+    
+    @Override
+    public void install( ProjectBuildingRequest buildingRequest, File localRepository,
+                         Collection<org.apache.maven.artifact.Artifact> mavenArtifacts
)
+                             throws ArtifactInstallerException
+    {
+     // prepare installRequest
         InstallRequest request = new InstallRequest();
 
         // transform artifacts
@@ -83,9 +96,15 @@ public class Maven30ArtifactInstaller
             }
         }
 
+        if ( localRepository != null )
+        {
+            buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest,
localRepository );
+        }
+
         RepositorySystemSession session =
             (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession"
);
 
+        
         // install
         try
         {

Modified: maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java?rev=1721728&r1=1721727&r2=1721728&view=diff
==============================================================================
--- maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
(original)
+++ maven/shared/trunk/maven-artifact-transfer/src/main/java/org/apache/maven/shared/artifact/install/internal/Maven31ArtifactInstaller.java
Sat Dec 26 12:44:09 2015
@@ -19,6 +19,7 @@ package org.apache.maven.shared.artifact
  * under the License.
  */
 
+import java.io.File;
 import java.util.Collection;
 
 import org.apache.maven.RepositoryUtils;
@@ -28,6 +29,7 @@ import org.apache.maven.project.ProjectB
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 import org.apache.maven.shared.artifact.install.ArtifactInstaller;
 import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
+import org.apache.maven.shared.artifact.repository.RepositoryManager;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.eclipse.aether.RepositorySystem;
@@ -48,11 +50,22 @@ public class Maven31ArtifactInstaller
     @Requirement
     private RepositorySystem repositorySystem;
 
-    /** {@inheritDoc} */
+    @Requirement
+    private RepositoryManager repositoryManager;
+
+    @Override
     public void install( ProjectBuildingRequest buildingRequest,
                          Collection<org.apache.maven.artifact.Artifact> mavenArtifacts
)
                              throws ArtifactInstallerException
     {
+        install( buildingRequest, null, mavenArtifacts );
+    }
+    
+    @Override
+    public void install( ProjectBuildingRequest buildingRequest, File localRepository,
+                         Collection<org.apache.maven.artifact.Artifact> mavenArtifacts
)
+                             throws ArtifactInstallerException
+    {
         // prepare installRequest
         InstallRequest request = new InstallRequest();
 
@@ -83,6 +96,11 @@ public class Maven31ArtifactInstaller
                 }
             }
         }
+        
+        if ( localRepository != null )
+        {
+            buildingRequest = repositoryManager.setLocalRepositoryBasedir( buildingRequest,
localRepository );
+        }
 
         RepositorySystemSession session =
             (RepositorySystemSession) Invoker.invoke( buildingRequest, "getRepositorySession"
);



Mime
View raw message