karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject [karaf] branch karaf-4.2.x updated: [KARAF-6119]karaf-maven-plugin assembly goal doesn't handle timestamp snapshots
Date Mon, 11 Mar 2019 11:09:51 GMT
This is an automated email from the ASF dual-hosted git repository.

ffang pushed a commit to branch karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
     new ab78741  [KARAF-6119]karaf-maven-plugin assembly goal doesn't handle timestamp snapshots
ab78741 is described below

commit ab787412baa16f64800aced5934565ccac2881e1
Author: Freeman Fang <freeman.fang@gmail.com>
AuthorDate: Mon Mar 11 19:09:00 2019 +0800

    [KARAF-6119]karaf-maven-plugin assembly goal doesn't handle timestamp snapshots
    
    (cherry picked from commit 11bda060bfc7fa7dd7893618a407ab87431a24f5)
---
 .../internal/download/impl/MavenDownloadTask.java  |  8 ++++++-
 .../java/org/apache/karaf/util/maven/Parser.java   | 28 +++++++++++++++++++++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadTask.java
b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadTask.java
index 7e878df..8465a7e 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadTask.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/download/impl/MavenDownloadTask.java
@@ -44,7 +44,13 @@ public class MavenDownloadTask extends AbstractRetryableDownloadTask {
 
     @Override
     protected File download(Exception previousException) throws Exception {
-        return resolver.resolve(url, previousException);
+                
+        try {
+            return resolver.resolve(url, previousException);
+        } catch (Exception ex) {
+            //try again with removing timestamp from snapshot 
+            return resolver.resolve(Parser.pathToMaven(Parser.pathFromMaven(url)), previousException);
+        }
     }
 
     /**
diff --git a/util/src/main/java/org/apache/karaf/util/maven/Parser.java b/util/src/main/java/org/apache/karaf/util/maven/Parser.java
index b39d856..814458f 100644
--- a/util/src/main/java/org/apache/karaf/util/maven/Parser.java
+++ b/util/src/main/java/org/apache/karaf/util/maven/Parser.java
@@ -20,6 +20,8 @@ package org.apache.karaf.util.maven;
 
 import java.net.MalformedURLException;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * Parser for mvn: protocol.
@@ -32,6 +34,7 @@ import java.util.Map;
 public class Parser
 {
 
+    private static final Pattern VERSION_FILE_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$"
);
     /**
      * Default version if none present in the url.
      */
@@ -418,7 +421,29 @@ public class Parser
      */
     public String getArtifactPath( final String version )
     {
-        return new StringBuilder()
+           
+        Matcher m = VERSION_FILE_PATTERN.matcher(version);
+
+        if ( m.matches() )
+        {
+            this.m_version = m.group( 1 ) + "-" + "SNAPSHOT";
+            String ret = new StringBuilder()
+                .append( m_group.replaceAll( GROUP_SEPARATOR, FILE_SEPARATOR ) )
+                .append( FILE_SEPARATOR )
+                .append( m_artifact )
+                .append( FILE_SEPARATOR )
+                .append( m_version )
+                .append( FILE_SEPARATOR )
+                .append( m_artifact )
+                .append( VERSION_SEPARATOR )
+                .append( m_version )
+                .append( m_fullClassifier )
+                .append( TYPE_SEPARATOR )
+                .append( m_type )
+                .toString();
+            return ret;
+        } else {
+            return new StringBuilder()
                 .append( m_group.replaceAll( GROUP_SEPARATOR, FILE_SEPARATOR ) )
                 .append( FILE_SEPARATOR )
                 .append( m_artifact )
@@ -432,6 +457,7 @@ public class Parser
                 .append( TYPE_SEPARATOR )
                 .append( m_type )
                 .toString();
+        }
     }
 
     /**


Mime
View raw message