tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r740211 - /tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java
Date Tue, 03 Feb 2009 05:01:06 GMT
Author: rfeng
Date: Tue Feb  3 05:01:06 2009
New Revision: 740211

URL: http://svn.apache.org/viewvc?rev=740211&view=rev
Log:
Fix the version generation 

Modified:
    tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java

Modified: tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java?rev=740211&r1=740210&r2=740211&view=diff
==============================================================================
--- tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java
(original)
+++ tuscany/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java
Tue Feb  3 05:01:06 2009
@@ -128,7 +128,7 @@
         if (file.isFile()) {
             Set<File> jars = new HashSet<File>();
             jars.add(file);
-            String name = file.getName().substring(0, file.getName().lastIndexOf(".jar"));
+            String name = file.getName();
             manifest = libraryManifest(jars, name, name, jarVersion(name), null);
         }
         return manifest;
@@ -410,23 +410,33 @@
         }
     }
     
-    private static Pattern pattern = Pattern.compile("-([0-9.]+)");
+    /**
+     * starting with -, then some digits, then . or - or _, then some digits again
+     * 
+     */
+    private static Pattern pattern = Pattern.compile("-(\\d)+((\\.|-|_)(\\d)+)*");
 
     /**
      * Returns the version number to use for the given JAR file.
      *   
-     * @param jarFile
+     * @param fileName
      * @return
      */
-    private static String jarVersion(String jarFile) {
-        Matcher matcher = pattern.matcher(jarFile);
+    static String jarVersion(String fileName) {
+        String name = fileName;
+        int index = name.lastIndexOf('.');
+        if (index != -1) {
+            // Trim the extension
+            name = name.substring(0, index);
+        }
+        
+        Matcher matcher = pattern.matcher(name);
         String version = "0.0.0";
         if (matcher.find()) {
-            version = matcher.group().substring(1); // Remove -
-            return osgiVersion(version);
-        } else {
-            return version;
+            version = matcher.group();
+            version = version.substring(1);
         }
+        return version;
     }
 
     /**



Mime
View raw message