You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/28 12:35:18 UTC

[sling-whiteboard] 01/01: Fix ArtifactId.toMvnId to be symmetrical with fromMvnId

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch feature/fix-artifact-id-to-mvn-id
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git

commit 9edaea6b5807062beeb09632a0f651ccd0242a14
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Tue Nov 28 14:33:10 2017 +0200

    Fix ArtifactId.toMvnId to be symmetrical with fromMvnId
    
    The fromMvnId method expects the values in the
    groupId:artifactId[:packaging[:classifier]]:version format,
    but toMvnId was outputting them in the
    groupId:artifactId:version[:packaging[:classifier]] format.
---
 .../feature/src/main/java/org/apache/sling/feature/ArtifactId.java   | 4 ++--
 .../src/test/java/org/apache/sling/feature/ArtifactIdTest.java       | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/featuremodel/feature/src/main/java/org/apache/sling/feature/ArtifactId.java b/featuremodel/feature/src/main/java/org/apache/sling/feature/ArtifactId.java
index a7231c8..9eca7a9 100644
--- a/featuremodel/feature/src/main/java/org/apache/sling/feature/ArtifactId.java
+++ b/featuremodel/feature/src/main/java/org/apache/sling/feature/ArtifactId.java
@@ -205,8 +205,6 @@ public class ArtifactId implements Comparable<ArtifactId> {
         sb.append(this.groupId);
         sb.append(':');
         sb.append(this.artifactId);
-        sb.append(':');
-        sb.append(version);
         if ( this.classifier != null || !"jar".equals(this.type)) {
             sb.append(':');
             sb.append(this.type);
@@ -215,6 +213,8 @@ public class ArtifactId implements Comparable<ArtifactId> {
                 sb.append(this.classifier);
             }
         }
+        sb.append(':');
+        sb.append(version);
         return sb.toString();
     }
 
diff --git a/featuremodel/feature/src/test/java/org/apache/sling/feature/ArtifactIdTest.java b/featuremodel/feature/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
index 958e117..2b01cdf 100644
--- a/featuremodel/feature/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
+++ b/featuremodel/feature/src/test/java/org/apache/sling/feature/ArtifactIdTest.java
@@ -141,4 +141,9 @@ public class ArtifactIdTest {
         assertEquals("zip", id.getType());
         assertEquals("foo", id.getClassifier());
     }
+
+    @Test public void testClassifierAndTypeToMvnId() {
+        final ArtifactId id = new ArtifactId("group.a", "artifact.b", "1.0", "foo", "zip");
+        assertEquals("group.a:artifact.b:zip:foo:1.0", id.toMvnId());
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.