summaryrefslogtreecommitdiffstats
path: root/java/sca/tools
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-02 18:09:34 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-02 18:09:34 +0000
commit275d67225ccc3a1e78889ce94a67916573f92f4d (patch)
tree2d58efda933ac031f227fbd66e8b10d1bd5393f7 /java/sca/tools
parentcb8100317e9ba4833d5a5dd028fc02cea07c2749 (diff)
Derive the osgi version from maven
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@740052 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.java23
1 files changed, 22 insertions, 1 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 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<File> jars = new HashSet<File>();
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