From a7d03cf5bb9b13a83a4a6b769d2cf10fb8aebae4 Mon Sep 17 00:00:00 2001
From: Stanislav Ochotnicky <sochotnicky@redhat.com>
Date: Tue, 2 Nov 2010 14:47:05 +0100
Subject: [PATCH 3/3] Use custom resolver

---
 .../org/apache/maven/artifact/ArtifactUtils.java   |    6 +++++-
 maven-core/pom.xml                                 |    4 ++++
 .../main/java/org/apache/maven/DefaultMaven.java   |    5 +++++
 .../apache/maven/plugin/MavenPluginValidator.java  |    3 ++-
 .../internal/DefaultPluginVersionResolver.java     |    7 +++++++
 .../model/validation/DefaultModelValidator.java    |    5 ++++-
 6 files changed, 27 insertions(+), 3 deletions(-)

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
index 1f37d4f..de2c8c8 100644
--- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
+++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java
@@ -104,7 +104,11 @@ public final class ArtifactUtils
             throw new NullPointerException( "version is null" );
         }
 
-        return groupId + ":" + artifactId + ":" + version;
+        if( System.getProperty("maven2.jpp.mode") == null ) {
+            return groupId + ":" + artifactId + ":" + version;
+        } else {
+            return versionlessKey(groupId, artifactId);
+        }
     }
 
     public static Map<String, Artifact> artifactMapByVersionlessId( Collection<Artifact> artifacts )
diff --git a/maven-core/pom.xml b/maven-core/pom.xml
index db9e82e..0d878ca 100644
--- a/maven-core/pom.xml
+++ b/maven-core/pom.xml
@@ -103,6 +103,10 @@
       <artifactId>commons-jxpath</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>JPP</groupId>
+      <artifactId>maven-javadir-resolver</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index e892ee9..5297959 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -361,6 +361,11 @@ public class DefaultMaven
             session.setWorkspaceReader( workspaceRepository );
         }
 
+        if ( System.getProperty("maven2.jpp.mode") != null)
+        {
+            session.setWorkspaceReader(new org.fedoraproject.maven.artifact.resolver.JavadirWorkspaceReader());
+        }
+
         DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest();
         decrypt.setProxies( request.getProxies() );
         decrypt.setServers( request.getServers() );
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
index 009635b..1fa25cb 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginValidator.java
@@ -60,7 +60,8 @@ public class MavenPluginValidator
             errors.add( "Plugin's descriptor contains the wrong artifact ID: " + pluginDescriptor.getArtifactId() );
         }
 
-        if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() ) )
+        if ( !pluginArtifact.getBaseVersion().equals( pluginDescriptor.getVersion() )
+             && System.getProperty("maven2.jpp.mode") == null)
         {
             errors.add( "Plugin's descriptor contains the wrong version: " + pluginDescriptor.getVersion() );
         }
diff --git a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
index fb074fb..78461e5 100644
--- a/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
+++ b/maven-core/src/main/java/org/apache/maven/plugin/version/internal/DefaultPluginVersionResolver.java
@@ -75,6 +75,13 @@ public class DefaultPluginVersionResolver
         throws PluginVersionResolutionException
     {
         logger.debug( "Resolving plugin version for " + request.getGroupId() + ":" + request.getArtifactId() );
+        if (System.getProperty("maven2.jpp.mode") != null) {
+            DefaultPluginVersionResult result = new DefaultPluginVersionResult("DUMMY_VER");
+            result.setRepository(request.getRepositorySession().getWorkspaceReader().getRepository());
+            logger.debug( "Resolved plugin version for " + request.getGroupId() + ":" + request.getArtifactId()
+                          + " to DUMMY_VER from repository " + result.getRepository());
+            return result;
+        }
 
         PluginVersionResult result = resolveFromProject( request );
 
diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
index 033211a..7976635 100644
--- a/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
+++ b/maven-model-builder/src/main/java/org/apache/maven/model/validation/DefaultModelValidator.java
@@ -405,7 +405,10 @@ public class DefaultModelValidator
 
                 if ( !management )
                 {
-                    validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
+                    if(System.getProperty("maven2.jpp.mode") != null && d.getVersion() == null)
+                        d.setVersion("DUMMY_VER");
+                    else
+                        validateVersion( prefix + "version", problems, errOn30, d.getVersion(), d.getManagementKey(), d );
 
                     /*
                      * TODO: Extensions like Flex Mojos use custom scopes like "merged", "internal", "external", etc.
-- 
1.7.3.2

