diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
new file mode 100644
index 0000000000..896df5479f
--- /dev/null
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -0,0 +1,40 @@
+package org.apache.maven.artifact;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public final class ArtifactUtils
+{
+
+ private ArtifactUtils()
+ {
+ }
+
+ public static String versionlessKey( Artifact artifact )
+ {
+ return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
+ }
+
+ public static String versionlessKey( String groupId, String artifactId )
+ {
+ return groupId + ":" + artifactId;
+ }
+
+ public static Map artifactMap( Collection artifacts )
+ {
+ Map artifactMap = new HashMap();
+
+ for ( Iterator it = artifacts.iterator(); it.hasNext(); )
+ {
+ Artifact artifact = (Artifact) it.next();
+
+ artifactMap.put( versionlessKey( artifact ), artifact );
+ }
+
+ return artifactMap;
+ }
+
+}
diff --git a/maven-mboot2/src/main/java/MBoot.java b/maven-mboot2/src/main/java/MBoot.java
index 6a869e48d4..0d6d2533e4 100644
--- a/maven-mboot2/src/main/java/MBoot.java
+++ b/maven-mboot2/src/main/java/MBoot.java
@@ -38,7 +38,7 @@ import java.util.TreeMap;
public class MBoot
{
String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
- "maven-plugin-descriptor", "maven-artifact", "maven-artifact-manager", "maven-artifact-test",
+ "maven-artifact", "maven-plugin-descriptor", "maven-artifact-manager", "maven-artifact-test",
"maven-plugin-mapping",
"maven-script/maven-script-beanshell", "maven-script/maven-script-marmalade", "maven-project", "maven-profile",
"maven-plugin-registry", "maven-reporting/maven-reporting-api", "maven-core", "maven-archiver",
diff --git a/maven-plugin-descriptor/pom.xml b/maven-plugin-descriptor/pom.xml
index 7d13924ca2..aa32992d62 100755
--- a/maven-plugin-descriptor/pom.xml
+++ b/maven-plugin-descriptor/pom.xml
@@ -15,6 +15,11 @@
maven-plugin-api
2.0-beta-1-SNAPSHOT
+
+ org.apache.maven
+ maven-artifact
+ 2.0-beta-1-SNAPSHOT
+
plexus
plexus-container-default
diff --git a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
index 549abd40e5..ce232a6b33 100644
--- a/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
+++ b/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
@@ -20,6 +20,8 @@ import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.classworlds.ClassRealm;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
import org.apache.maven.plugin.lifecycle.Lifecycle;
import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
@@ -60,6 +62,9 @@ public class PluginDescriptor
private ClassRealm classRealm;
+ // calculated on-demand.
+ private Map artifactMap;
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
@@ -216,6 +221,19 @@ public class PluginDescriptor
public void setArtifacts( List artifacts )
{
this.artifacts = artifacts;
+
+ // clear the calculated artifactMap
+ artifactMap = null;
+ }
+
+ public Map getArtifactMap()
+ {
+ if ( artifactMap == null )
+ {
+ artifactMap = ArtifactUtils.artifactMap( getArtifacts() );
+ }
+
+ return artifactMap;
}
public boolean equals( Object object )
diff --git a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
index f867fb7e5b..849e7ce587 100644
--- a/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
@@ -17,6 +17,7 @@ package org.apache.maven.project;
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Build;
@@ -49,6 +50,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -105,6 +107,9 @@ public class MavenProject
private Artifact artifact;
+ // calculated.
+ private Map artifactMap;
+
public MavenProject( Model model )
{
this.model = model;
@@ -782,6 +787,9 @@ public class MavenProject
public void setArtifacts( Set artifacts )
{
this.artifacts = artifacts;
+
+ // flush the calculated artifactMap
+ artifactMap = null;
}
public Set getArtifacts()
@@ -789,6 +797,16 @@ public class MavenProject
return artifacts;
}
+ public Map getArtifactMap()
+ {
+ if ( artifactMap == null )
+ {
+ artifactMap = ArtifactUtils.artifactMap( getArtifacts() );
+ }
+
+ return artifactMap;
+ }
+
public void setPluginArtifacts( Set pluginArtifacts )
{
this.pluginArtifacts = pluginArtifacts;