From 275d67225ccc3a1e78889ce94a67916573f92f4d Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 2 Feb 2009 18:09:34 +0000 Subject: Derive the osgi version from maven git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@740052 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/tools/maven/compiler/osgi/BundleUtil.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'java/sca/tools') 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 9e99fe4790..738e4255e6 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 @@ -44,6 +44,8 @@ import java.util.StringTokenizer; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -127,7 +129,7 @@ public final class BundleUtil { Set jars = new HashSet(); jars.add(file); String name = file.getName().substring(0, file.getName().lastIndexOf(".jar")); - manifest = libraryManifest(jars, name, name, "0.0.0", null); + manifest = libraryManifest(jars, name, name, jarVersion(name), null); } return manifest; } @@ -407,6 +409,25 @@ public final class BundleUtil { } } } + + private static Pattern pattern = Pattern.compile("-([0-9.]+)"); + + /** + * Returns the version number to use for the given JAR file. + * + * @param jarFile + * @return + */ + private static String jarVersion(String jarFile) { + Matcher matcher = pattern.matcher(jarFile); + String version = "0.0.0"; + if (matcher.find()) { + version = matcher.group().substring(1); // Remove - + return osgiVersion(version); + } else { + return version; + } + } /** * Convert the maven version into OSGi version -- cgit v1.2.3