aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1629224 - in /aries/trunk/esa-maven-plugin/src: main/java/org/apache/aries/plugin/esa/ test/java/org/apache/aries/plugin/esa/ test/java/org/apache/aries/plugin/esa/stubs/
Date Fri, 03 Oct 2014 15:16:08 GMT
Author: davidb
Date: Fri Oct  3 15:16:08 2014
New Revision: 1629224

URL: http://svn.apache.org/r1629224
Log:
[ARIES-1255] Support Subsystem-Content version ranges from Maven version ranges

If a Maven version range is specified in the Maven dependency, then use this range as the
version range in the generated Subsystem-Content header. For example:
  <dependency>
    <groupId>org.foo.bar</groupId>
    <artifactId>mybundle</artifactId>
    <version>[3.0, 3.8.2)</version>
  </dependency>
Will generate a subsystem content header of:
  Subsystem-Content: mySymbolicName;version="[3.0,3.8.2)"

For Maven dependencies that don't use a version range the version is declared as version="[a.b.c,a.b.c]"

Unit test included.

Modified:
    aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/ContentInfo.java
    aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
    aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaArtifactStub.java
    aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub9.java

Modified: aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/ContentInfo.java
URL: http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/ContentInfo.java?rev=1629224&r1=1629223&r2=1629224&view=diff
==============================================================================
--- aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/ContentInfo.java
(original)
+++ aries/trunk/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/ContentInfo.java
Fri Oct  3 15:16:08 2014
@@ -30,6 +30,7 @@ import java.util.zip.ZipFile;
 import aQute.lib.osgi.Analyzer;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
@@ -44,6 +45,7 @@ public class ContentInfo {
     private String symbolicName;
     private String type;
     private String version;
+    private VersionRange mavenVersionRange;
 
     public String getSymbolicName() {
         return symbolicName;
@@ -62,8 +64,12 @@ public class ContentInfo {
         if (type != null) {
             line += ";type=\"" + type + "\"";
         }
-        if (version != null) {
-            line += ";version=\"[" + version + "," + version + "]\"";
+        if (mavenVersionRange != null && mavenVersionRange.hasRestrictions()) {
+            line += ";version=\"" + mavenVersionRange + '"';
+        } else {
+            if (version != null) {
+                line += ";version=\"[" + version + "," + version + "]\"";
+            }
         }
         return line;
     }
@@ -101,6 +107,7 @@ public class ContentInfo {
         ContentInfo info = new ContentInfo();
         info.symbolicName = maven2OsgiConverter.getBundleSymbolicName(artifact);
         info.version = Analyzer.cleanupVersion(artifact.getVersion());
+        info.mavenVersionRange = artifact.getVersionRange();
         return info;
     }
 
@@ -128,6 +135,7 @@ public class ContentInfo {
             info.type = header.keySet().iterator().next();
         }
 
+        info.mavenVersionRange = artifact.getVersionRange();
         return info;
     }
 
@@ -153,6 +161,7 @@ public class ContentInfo {
                 info.type = Constants.FRAGMENT_TYPE;
             }
 
+            info.mavenVersionRange = artifact.getVersionRange();
             return info;
         }
     }

Modified: aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java?rev=1629224&r1=1629223&r2=1629224&view=diff
==============================================================================
--- aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
(original)
+++ aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java
Fri Oct  3 15:16:08 2014
@@ -567,7 +567,7 @@ public class EsaMojoTest
 
         attributes = header.get("maven-artifact02-1.0-SNAPSHOT");
         assertNotNull(attributes);
-        assertEquals("[1.0.0.SNAPSHOT,1.0.0.SNAPSHOT]", attributes.get("version"));
+        assertEquals("[1.3,2.5)", attributes.get("version"));
         assertNull(attributes.get("type"));
 
         attributes = header.get("maven-artifact03");

Modified: aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaArtifactStub.java
URL: http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaArtifactStub.java?rev=1629224&r1=1629223&r2=1629224&view=diff
==============================================================================
--- aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaArtifactStub.java
(original)
+++ aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaArtifactStub.java
Fri Oct  3 15:16:08 2014
@@ -21,6 +21,7 @@ package org.apache.aries.plugin.esa.stub
 
 import java.io.File;
 
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 
 /**
@@ -30,17 +31,19 @@ public class EsaArtifactStub
     extends ArtifactStub
 {
     private String groupId;
-    
+
     private String artifactId;
-    
+
     private String version;
-    
+
     private String scope;
-    
+
     private boolean optional;
-    
+
     private File file;
 
+    private VersionRange versionRange;
+
     public String getArtifactId()
     {
         return artifactId;
@@ -105,9 +108,19 @@ public class EsaArtifactStub
     {
         return getGroupId() + ":" + getArtifactId() + ":" + getVersion();
     }
-    
+
     public String getBaseVersion()
     {
         return getVersion();
     }
+
+    @Override
+    public VersionRange getVersionRange() {
+        return versionRange;
+    }
+
+    @Override
+    public void setVersionRange(VersionRange versionRange) {
+        this.versionRange = versionRange;
+    }
 }

Modified: aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub9.java
URL: http://svn.apache.org/viewvc/aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub9.java?rev=1629224&r1=1629223&r2=1629224&view=diff
==============================================================================
--- aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub9.java
(original)
+++ aries/trunk/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub9.java
Fri Oct  3 15:16:08 2014
@@ -23,6 +23,10 @@ import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+
 public class EsaMavenProjectStub9
     extends EsaMavenProjectStub
 {
@@ -30,15 +34,24 @@ public class EsaMavenProjectStub9
     {
         return new File( getBasedir(), "src/test/resources/unit/basic-esa-content-type/plugin-config.xml"
);
     }
-    
+
     public Set getArtifacts()
-    {   
-        Set artifacts = new HashSet();
- 
-        artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact01", "1.0-SNAPSHOT",
false ) );
-        artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact02", "1.0-SNAPSHOT",
false ) );
-        artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact03", "1.1-SNAPSHOT",
false ) );
-        artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact04", "1.2-SNAPSHOT",
"esa", true ) );
-        return artifacts;
+    {
+        try
+        {
+            Set artifacts = new HashSet();
+
+            artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact01", "1.0-SNAPSHOT",
false ) );
+            Artifact artifact02 = createArtifact( "org.apache.maven.test", "maven-artifact02",
"1.0-SNAPSHOT", false );
+            artifact02.setVersionRange(VersionRange.createFromVersionSpec("[1.3, 2.5)"));
+            artifacts.add( artifact02 );
+            artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact03", "1.1-SNAPSHOT",
false ) );
+            artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact04", "1.2-SNAPSHOT",
"esa", true ) );
+            return artifacts;
+        }
+        catch (InvalidVersionSpecificationException e)
+        {
+            throw new RuntimeException(e);
+        }
     }
 }



Mime
View raw message