You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2017/08/07 15:46:15 UTC

karaf git commit: [KARAF-4655] Fix handling of mvn urls with repositories and parameters

Repository: karaf
Updated Branches:
  refs/heads/master 5c2185108 -> 3348f54b4


[KARAF-4655] Fix handling of mvn urls with repositories and parameters


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3348f54b
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3348f54b
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3348f54b

Branch: refs/heads/master
Commit: 3348f54b4e0a521260b73a5c8fd591ba4b1a7494
Parents: 5c21851
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Aug 7 17:45:52 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Aug 7 17:45:52 2017 +0200

----------------------------------------------------------------------
 .../apache/karaf/tooling/utils/MojoSupport.java | 13 ++++---
 .../tooling/features/BundleToArtifactTest.java  | 37 +++++++++++++-------
 2 files changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/3348f54b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MojoSupport.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MojoSupport.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MojoSupport.java
index 4b78c5e..ea79b40 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MojoSupport.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/utils/MojoSupport.java
@@ -275,9 +275,12 @@ public abstract class MojoSupport extends AbstractMojo {
         //check if the resourceLocation descriptor contains also remote repository information.
         ArtifactRepository repo = null;
         if (resourceLocation.startsWith("http://")) {
-            final int repoDelimIntex = resourceLocation.indexOf('!');
-            String repoUrl = resourceLocation.substring(0, repoDelimIntex);
-
+            final int repoDelimIndex = resourceLocation.indexOf('!');
+            String repoUrl = resourceLocation.substring(0, repoDelimIndex);
+            int paramIndex = repoUrl.indexOf("@");
+            if (paramIndex >= 0) {
+                repoUrl = repoUrl.substring(0, paramIndex);
+            }
             repo = new DefaultArtifactRepository(
                     repoUrl,
                     repoUrl,
@@ -286,9 +289,9 @@ public abstract class MojoSupport extends AbstractMojo {
             if (mavenProxy != null) {
                 repo.setProxy(mavenProxy);
             }
-            resourceLocation = resourceLocation.substring(repoDelimIntex + 1);
-
+            resourceLocation = resourceLocation.substring(repoDelimIndex + 1);
         }
+
         String[] parts = resourceLocation.split("/");
         String groupId = parts[0];
         String artifactId = parts[1];

http://git-wip-us.apache.org/repos/asf/karaf/blob/3348f54b/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/features/BundleToArtifactTest.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/features/BundleToArtifactTest.java b/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/features/BundleToArtifactTest.java
index 7adb1de..4ce989d 100644
--- a/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/features/BundleToArtifactTest.java
+++ b/tooling/karaf-maven-plugin/src/test/java/org/apache/karaf/tooling/features/BundleToArtifactTest.java
@@ -30,8 +30,10 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.junit.Assert;
 import org.junit.Test;
 
+
 public class BundleToArtifactTest extends MojoSupport {
 
     @SuppressWarnings("rawtypes")
@@ -66,22 +68,33 @@ public class BundleToArtifactTest extends MojoSupport {
     @Test
     public void testURLWithClassifier() throws Exception {
         Artifact artifact = resourceToArtifact("mvn:org.foo/bar/1.0/kar/type", false);
-        assert artifact.getGroupId().equals("org.foo");
-        assert artifact.getArtifactId().equals("bar");
-        assert artifact.getBaseVersion().equals("1.0");
-        assert artifact.getType().equals("kar");
-        assert artifact.getRepository() == null;
-        assert artifact.getClassifier().equals("type");
+        Assert.assertEquals("org.foo", artifact.getGroupId());
+        Assert.assertEquals("bar", artifact.getArtifactId());
+        Assert.assertEquals("1.0", artifact.getBaseVersion());
+        Assert.assertEquals("kar", artifact.getType());
+        Assert.assertNull(artifact.getRepository());
+        Assert.assertEquals("type", artifact.getClassifier());
     }
 
     @Test
     public void testRemoteRepoURL() throws Exception {
         Artifact artifact = resourceToArtifact("mvn:http://baz.com!org.foo/bar/1.0/kar", false);
-        assert artifact.getGroupId().equals("org.foo");
-        assert artifact.getArtifactId().equals("bar");
-        assert artifact.getBaseVersion().equals("1.0");
-        assert artifact.getType().equals("kar");
-        assert artifact.getRepository().getUrl().equals("http://baz.com");
-        assert artifact.getClassifier() == null;
+        Assert.assertEquals("org.foo", artifact.getGroupId());
+        Assert.assertEquals("bar", artifact.getArtifactId());
+        Assert.assertEquals("1.0", artifact.getBaseVersion());
+        Assert.assertEquals("kar", artifact.getType());
+        Assert.assertEquals("http://baz.com", artifact.getRepository().getUrl());
+        Assert.assertNull(artifact.getClassifier());
+    }
+    
+    @Test
+    public void testRemoteRepoURLWithId() throws Exception {
+        Artifact artifact = resourceToArtifact("mvn:http://baz.com@id=baz!org.foo/bar/1.0/kar", false);
+        Assert.assertEquals("org.foo", artifact.getGroupId());
+        Assert.assertEquals("bar", artifact.getArtifactId());
+        Assert.assertEquals("1.0", artifact.getBaseVersion());
+        Assert.assertEquals("kar", artifact.getType());
+        Assert.assertEquals("http://baz.com", artifact.getRepository().getUrl());
+        Assert.assertNull(artifact.getClassifier());
     }
 }