You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2008/05/22 05:01:47 UTC

svn commit: r658985 - in /geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car: AbstractCarMojo.java InstallModulesMojo.java PackageMojo.java

Author: djencks
Date: Wed May 21 20:01:46 2008
New Revision: 658985

URL: http://svn.apache.org/viewvc?rev=658985&view=rev
Log:
GERONIMO-4039 Don't try to resolve artifacts to what maven thought of it the version is explicitly supplied

Modified:
    geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
    geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
    geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java

Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java?rev=658985&r1=658984&r2=658985&view=diff
==============================================================================
--- geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java (original)
+++ geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/AbstractCarMojo.java Wed May 21 20:01:46 2008
@@ -384,12 +384,6 @@
     protected class ArtifactLookupImpl
             implements Maven2RepositoryAdapter.ArtifactLookup {
 
-        private final Map<org.apache.geronimo.kernel.repository.Artifact, Artifact> resolvedArtifacts;
-
-        public ArtifactLookupImpl(Map<org.apache.geronimo.kernel.repository.Artifact, Artifact> resolvedArtifacts) {
-            this.resolvedArtifacts = resolvedArtifacts;
-        }
-
         public File getBasedir() {
             String path = getArtifactRepository().getBasedir();
             return new File(path);
@@ -404,63 +398,33 @@
 
         public File getLocation(final org.apache.geronimo.kernel.repository.Artifact artifact) {
             assert artifact != null;
+            Artifact mavenArtifact;
 
-            boolean debug = getLog().isDebugEnabled();
+            // Do not attempt to resolve an artifact that is the same as the project
+            if (isProjectArtifact(artifact) && artifact.getVersion() == null) {
+                throw new IllegalStateException("WTF? project has no version??");
+            }
 
-            Artifact mavenArtifact = resolvedArtifacts.get(artifact);
+            if (artifact.getVersion() == null) {
+                if (log.isDebugEnabled()) {
+                    getLog().debug("Resolving artifact: " + artifact);
+                }
+                mavenArtifact = resolveArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getType());
 
-            // If not cached, then make a new artifact
-            if (mavenArtifact == null) {
+            } else {
                 mavenArtifact = artifactFactory.createArtifactWithClassifier(
                         artifact.getGroupId(),
                         artifact.getArtifactId(),
                         artifact.getVersion().toString(),
                         artifact.getType(),
-                        null
-                );
-            }
-
-            // Do not attempt to resolve an artifact that is the same as the project
-            if (isProjectArtifact(artifact)) {
-                if (debug) {
-                    getLog().debug("Skipping resolution of project artifact: " + artifact);
-                }
-
-                //
-                // HACK: Still have to return something, otherwise some CAR packaging will fail...
-                //       no idea what is using this file, or if the files does exist if that will be
-                //       used instead of any details we are currently building
-                //
-                return new File(getBasedir(), getArtifactRepository().pathOf(mavenArtifact));
+                        null);
             }
 
-            File file;
-            if (!mavenArtifact.isResolved()) {
-                if (debug) {
-                    getLog().debug("Resolving artifact: " + mavenArtifact);
-                }
-                mavenArtifact = resolveArtifact(mavenArtifact);
-
-                // Cache the resolved artifact
-                resolvedArtifacts.put(artifact, mavenArtifact);
-            }
-
-            //
-            // HACK: Construct the real local filename from the path and resolved artifact file.
-            //       Probably a better way to do this with the Maven API directly, but this is the
-            //       best I can do for now.
-            //
             String path = getArtifactRepository().pathOf(mavenArtifact);
-            file = new File(getBasedir(), path);
-
-            return file;
+            return new File(getBasedir(), path);
         }
     }
 
-    protected Artifact resolveArtifact(Artifact mavenArtifact) {
-        return resolveArtifact(mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(), mavenArtifact.getType());
-    }
-
     protected Artifact resolveArtifact(String groupId, String artifactId, String type) {
         for (Artifact artifact : dependencies) {
             if (matches(groupId, artifactId, type, artifact)) {

Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java?rev=658985&r1=658984&r2=658985&view=diff
==============================================================================
--- geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java (original)
+++ geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/InstallModulesMojo.java Wed May 21 20:01:46 2008
@@ -20,11 +20,9 @@
 package org.apache.geronimo.mavenplugins.car;
 
 import java.io.File;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.LinkedHashSet;
 
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.basic.BasicKernel;
@@ -40,11 +38,8 @@
 import org.apache.geronimo.system.plugin.model.PluginType;
 import org.apache.geronimo.system.resolver.AliasedArtifactResolver;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.ProjectBuildingException;
 
 /**
  * Installs Geronimo module CAR files into a target repository to support assembly.
@@ -139,7 +134,7 @@
 
     public void execute() throws MojoExecutionException, MojoFailureException {
         getDependencies(project, false);
-        Maven2RepositoryAdapter.ArtifactLookup lookup = new ArtifactLookupImpl(new HashMap<Artifact, org.apache.maven.artifact.Artifact>());
+        Maven2RepositoryAdapter.ArtifactLookup lookup = new ArtifactLookupImpl();
         SourceRepository sourceRepo = new Maven2RepositoryAdapter(dependencies, lookup);
         PluginListType pluginList = new PluginListType();
         String localRepo = sourceRepository.getUrl();

Modified: geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java?rev=658985&r1=658984&r2=658985&view=diff
==============================================================================
--- geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java (original)
+++ geronimo/server/trunk/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java Wed May 21 20:01:46 2008
@@ -22,7 +22,6 @@
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -195,7 +194,7 @@
             // NOTE: Install a local lookup, so that the cached kernel can resolve based on the current project
             //       and not the project where the kernel was first initialized.
             //
-            lookupHolder.set(new ArtifactLookupImpl(new HashMap()));
+            lookupHolder.set(new ArtifactLookupImpl());
 
             if (bootstrap) {
                 executeBootShell();