You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/02/24 14:39:21 UTC
svn commit: r747379 -
/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
Author: bentmann
Date: Tue Feb 24 13:39:20 2009
New Revision: 747379
URL: http://svn.apache.org/viewvc?rev=747379&view=rev
Log:
o Prevented multiple installations of same artifact
Modified:
maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java?rev=747379&r1=747378&r2=747379&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java Tue Feb 24 13:39:20 2009
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
@@ -122,6 +123,11 @@
private boolean skipInstallation;
/**
+ * The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact.
+ */
+ private Collection installedArtifacts;
+
+ /**
* Performs this mojo's tasks.
*
* @throws MojoExecutionException If the artifacts could not be installed.
@@ -137,9 +143,11 @@
ArtifactRepository testRepository = createTestRepository();
- installProjectDependencies( project, reactorProjects, testRepository );
- installProjectParents( project, testRepository );
+ installedArtifacts = new HashSet();
+
installProjectArtifacts( project, testRepository );
+ installProjectParents( project, testRepository );
+ installProjectDependencies( project, reactorProjects, testRepository );
}
/**
@@ -205,7 +213,15 @@
{
throw new IllegalStateException( "Artifact is not fully assembled: " + file );
}
- installer.install( file, artifact, testRepository );
+
+ if ( installedArtifacts.add( artifact.getId() ) )
+ {
+ installer.install( file, artifact, testRepository );
+ }
+ else
+ {
+ getLog().debug( "Not re-installing " + artifact + ", " + file );
+ }
}
catch ( Exception e )
{
@@ -332,7 +348,7 @@
}
// collect transitive dependencies
- Collection dependencies = new HashSet();
+ Collection dependencies = new LinkedHashSet();
for ( Iterator it = mvnProject.getArtifacts().iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
@@ -428,10 +444,15 @@
{
Artifact pomArtifact = artifactFactory.createProjectArtifact( groupId, artifactId, version );
+ if ( installedArtifacts.contains( pomArtifact.getId() ) )
+ {
+ getLog().debug( "Not re-installing " + pomArtifact );
+ return;
+ }
+
File pomFile = new File( localRepository.getBasedir(), localRepository.pathOf( pomArtifact ) );
if ( pomFile.isFile() )
{
- // TODO: track which parents were already installed to prevent needless re-installation
installArtifact( pomFile, pomArtifact, testRepository );
installParentPoms( pomFile, testRepository );
}