summaryrefslogtreecommitdiffstats
path: root/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java')
-rw-r--r--maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java43
1 files changed, 28 insertions, 15 deletions
diff --git a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java
index 68166931fa..cb44d1bfdc 100644
--- a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java
+++ b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/BundleUtil.java
@@ -32,6 +32,7 @@ import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set;
@@ -60,32 +61,44 @@ final class BundleUtil {
* @throws IOException
*/
static String getBundleSymbolicName(File file) throws IOException {
+ Manifest manifest = getManifest(file);
+ return getBundleSymbolicName(manifest);
+ }
+
+ static String getBundleSymbolicName(Manifest manifest) {
+ if (manifest == null) {
+ return null;
+ }
+
+ String bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ if (bundleName == null) {
+ return bundleName;
+ }
+ int sc = bundleName.indexOf(';');
+ if (sc != -1) {
+ bundleName = bundleName.substring(0, sc);
+ }
+ return bundleName;
+ }
+
+ static Manifest getManifest(File file) throws IOException {
if (!file.exists()) {
return null;
}
- String bundleName = null;
+ Manifest manifest = null;
if (file.isDirectory()) {
File mf = new File(file, "META-INF/MANIFEST.MF");
if (mf.isFile()) {
- Manifest manifest = new Manifest(new FileInputStream(mf));
- bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
+ InputStream is = new FileInputStream(mf);
+ manifest = new Manifest(new FileInputStream(mf));
+ is.close();
}
} else {
JarFile jar = new JarFile(file, false);
- Manifest manifest = jar.getManifest();
- if (manifest != null){
- bundleName = manifest.getMainAttributes().getValue(BUNDLE_SYMBOLICNAME);
- }
+ manifest = jar.getManifest();
jar.close();
}
- if (bundleName == null) {
- return bundleName;
- }
- int sc = bundleName.indexOf(';');
- if (sc != -1) {
- bundleName = bundleName.substring(0, sc);
- }
- return bundleName;
+ return manifest;
}
/**