incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1070487 - /sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Date Mon, 14 Feb 2011 13:56:46 GMT
Author: justin
Date: Mon Feb 14 13:56:46 2011
New Revision: 1070487

URL: http://svn.apache.org/viewvc?rev=1070487&view=rev
Log:
SLING-1980 - fixing by adding some code as described by Benjamin on maven-users

Modified:
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java?rev=1070487&r1=1070486&r2=1070487&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Mon Feb 14 13:56:46 2011
@@ -24,10 +24,13 @@ import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.execution.MavenSession;
@@ -129,6 +132,13 @@ public abstract class AbstractBundleList
     private ArtifactFactory factory;
 
     /**
+     * Used to look up Artifacts in the remote repository.
+     *
+     * @component hint="maven"
+     */
+    private ArtifactMetadataSource metadataSource;
+
+    /**
      * If true, include the default bundles.
      *
      * @parameter default-value="true"
@@ -225,6 +235,19 @@ public abstract class AbstractBundleList
             artifact = factory.createDependencyArtifact(groupId, artifactId, vr, type, classifier,
                     Artifact.SCOPE_COMPILE);
         }
+
+        // This code kicks in when the version specifier is a range.
+        if (vr.getRecommendedVersion() == null) {
+            try {
+                List availVersions = metadataSource.retrieveAvailableVersions(artifact, local,
remoteRepos);
+                ArtifactVersion resolvedVersion = vr.matchVersion(availVersions);
+                artifact.setVersion(resolvedVersion.toString());
+            } catch (ArtifactMetadataRetrievalException e) {
+                throw new MojoExecutionException("Unable to find version for artifact", e);
+            }
+            
+        }
+
         try {
             resolver.resolve(artifact, remoteRepos, local);
         } catch (ArtifactResolutionException e) {



Mime
View raw message