You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/09/29 20:10:04 UTC

svn commit: r451371 - /geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java

Author: jdillon
Date: Fri Sep 29 11:10:04 2006
New Revision: 451371

URL: http://svn.apache.org/viewvc?view=rev&rev=451371
Log:
Support for version ranges

Modified:
    geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java

Modified: geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java?view=diff&rev=451371&r1=451370&r2=451371
==============================================================================
--- geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java (original)
+++ geronimo/genesis/trunk/plugins/plugin-support/src/main/java/org/apache/geronimo/genesis/MojoSupport.java Fri Sep 29 11:10:04 2006
@@ -28,6 +28,8 @@
 import org.apache.maven.project.MavenProject;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -118,6 +120,10 @@
         // Empty
     }
 
+    //
+    // NOTE: These are not abstract because not all sub-classes will need this functionality
+    //
+    
     /**
      * Get the Maven project.
      *
@@ -163,8 +169,6 @@
      * list or from the DependencyManagement section of the pom.
      */
     protected Artifact createArtifact(final ArtifactItem item) throws MojoExecutionException {
-        Artifact artifact;
-
         if (item.getVersion() == null) {
             fillMissingArtifactVersion(item);
 
@@ -175,23 +179,22 @@
 
         }
 
-        String classifier = item.getClassifier();
-        if (classifier == null || classifier.equals("")) {
-            artifact = getArtifactFactory().createArtifact(
-                    item.getGroupId(),
-                    item.getArtifactId(),
-                    item.getVersion(),
-                    Artifact.SCOPE_PROVIDED,
-                    item.getType());
+        // Convert the string version to a range
+        VersionRange range;
+        try {
+            range = VersionRange.createFromVersionSpec(item.getVersion());
         }
-        else {
-            artifact = getArtifactFactory().createArtifactWithClassifier(
-                    item.getGroupId(),
-                    item.getArtifactId(),
-                    item.getVersion(),
-                    item.getType(),
-                    item.getClassifier());
+        catch (InvalidVersionSpecificationException e) {
+            throw new MojoExecutionException("Could not create range for version: " + item.getVersion(), e);
         }
+        
+        Artifact artifact = getArtifactFactory().createDependencyArtifact(
+            item.getGroupId(),
+            item.getArtifactId(),
+            range,
+            item.getType(),
+            item.getClassifier(),
+            Artifact.SCOPE_PROVIDED);
 
         return artifact;
     }