Author: rfscholte
Date: Sat Jul 4 22:10:45 2015
New Revision: 1689196
URL: http://svn.apache.org/r1689196
Log:
'copy-dependencies' now uses ArtifactInstaller from maven-artifact-transfer
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/CopyDependenciesMojo.java
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java?rev=1689196&r1=1689195&r2=1689196&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyMojo.java
Sat Jul 4 22:10:45 2015
@@ -361,15 +361,7 @@ public abstract class AbstractDependency
return this.project;
}
- /**
- * @return Returns the local.
- */
- protected ArtifactRepository getLocal()
- {
- throw new UnsupportedOperationException( "Don't use this anymore. " );
- }
-
- /**
+ /**
* @return Returns the remoteRepos.
*/
public List<ArtifactRepository> getRemoteRepos()
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java?rev=1689196&r1=1689195&r2=1689196&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
Sat Jul 4 22:10:45 2015
@@ -510,4 +510,9 @@ public abstract class AbstractDependency
{
return artifactResolver;
}
+
+ protected final RepositoryManager getRepositoryManager()
+ {
+ return repositoryManager;
+ }
}
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/CopyDependenciesMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/CopyDependenciesMojo.java?rev=1689196&r1=1689195&r2=1689196&view=diff
==============================================================================
---
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/CopyDependenciesMojo.java
(original)
+++
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/CopyDependenciesMojo.java
Sat Jul 4 22:10:45 2015
@@ -20,9 +20,6 @@ package org.apache.maven.plugin.dependen
*/
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.installer.ArtifactInstallationException;
-import org.apache.maven.artifact.installer.ArtifactInstaller;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.plugin.MojoExecutionException;
@@ -37,10 +34,12 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import org.apache.maven.shared.artifact.install.ArtifactInstaller;
+import org.apache.maven.shared.artifact.install.ArtifactInstallerException;
import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
import java.io.File;
-import java.net.MalformedURLException;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -69,7 +68,7 @@ public class CopyDependenciesMojo
*
*/
@Component
- protected ArtifactInstaller installer;
+ private ArtifactInstaller installer;
/**
*
@@ -136,21 +135,13 @@ public class CopyDependenciesMojo
}
else
{
- try
- {
- ArtifactRepository targetRepository =
- repositoryFactory.createDeploymentArtifactRepository(
"local",
-
outputDirectory.toURL().toExternalForm(),
-
repositoryLayouts.get( "default" ),
-
false /* uniqueVersion */ );
- for ( Artifact artifact : artifacts )
- {
- installArtifact( artifact, targetRepository );
- }
- }
- catch ( MalformedURLException e )
+ ProjectBuildingRequest buildingRequest =
+ getRepositoryManager().setLocalRepositoryBasedir(
session.getProjectBuildingRequest(),
+
outputDirectory );
+
+ for ( Artifact artifact : artifacts )
{
- throw new MojoExecutionException( "Could not create
outputDirectory repository", e );
+ installArtifact( artifact, buildingRequest );
}
}
@@ -174,46 +165,39 @@ public class CopyDependenciesMojo
* @param artifact
* @param targetRepository
*/
- private void installArtifact( Artifact artifact, ArtifactRepository
targetRepository )
+ private void installArtifact( Artifact artifact, ProjectBuildingRequest
buildingRequest )
{
try
{
- if ( "pom".equals( artifact.getType() ) )
- {
- installer.install( artifact.getFile(), artifact,
targetRepository );
- installBaseSnapshot( artifact, targetRepository );
- }
- else
- {
- installer.install( artifact.getFile(), artifact,
targetRepository );
- installBaseSnapshot( artifact, targetRepository );
+ installer.install( buildingRequest, Collections.singletonList(
artifact ) );
+ installBaseSnapshot( artifact, buildingRequest );
- if ( isCopyPom() )
+ if ( !"pom".equals( artifact.getType() ) && isCopyPom() )
+ {
+ Artifact pomArtifact = getResolvedPomArtifact( artifact );
+ if ( pomArtifact.getFile() != null &&
pomArtifact.getFile().exists() )
{
- Artifact pomArtifact = getResolvedPomArtifact( artifact );
- if ( pomArtifact.getFile() != null &&
pomArtifact.getFile().exists() )
- {
- installer.install( pomArtifact.getFile(), pomArtifact,
targetRepository );
- installBaseSnapshot( pomArtifact, targetRepository );
- }
+ installer.install( buildingRequest,
Collections.singletonList( pomArtifact ) );
+ installBaseSnapshot( pomArtifact, buildingRequest );
}
}
}
- catch ( ArtifactInstallationException e )
+ catch ( ArtifactInstallerException e )
{
getLog().warn( "unable to install " + artifact, e );
}
}
- private void installBaseSnapshot( Artifact artifact, ArtifactRepository
targetRepository )
- throws ArtifactInstallationException
+ private void installBaseSnapshot( Artifact artifact,
ProjectBuildingRequest buildingRequest )
+ throws ArtifactInstallerException
{
if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals(
artifact.getVersion() ) )
{
Artifact baseArtifact =
this.factory.createArtifact( artifact.getGroupId(),
artifact.getArtifactId(), artifact.getBaseVersion(),
artifact.getScope(),
artifact.getType() );
- installer.install( artifact.getFile(), baseArtifact,
targetRepository );
+ baseArtifact.setFile( artifact.getFile() );
+ installer.install( buildingRequest, Collections.singletonList(
baseArtifact ) );
}
}