diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-03 05:01:06 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-03 05:01:06 +0000 |
commit | 98cb3a65fba02d3e1b3375d9216b34b25aa3e798 (patch) | |
tree | 4a2701867318504fcb2e79aab7b522eb8e58426e /java/sca/tools | |
parent | d2fc9a2a035de29ef1a1669d7a96e44e48cbf1b5 (diff) |
Fix the version generation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@740211 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/tools')
-rw-r--r-- | java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java b/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java index 738e4255e6..be8ee92fb6 100644 --- a/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java +++ b/java/sca/tools/maven/maven-eclipse-compiler/src/main/java/org/apache/tuscany/sca/tools/maven/compiler/osgi/BundleUtil.java @@ -128,7 +128,7 @@ public final class BundleUtil { 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 @@ public final class BundleUtil { } } - 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; } /** |