summaryrefslogtreecommitdiffstats
path: root/maven-plugins
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-02-04 14:28:54 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-02-04 14:28:54 +0000
commit1b9131932b52a615c7481a293a411c56ffd63c2d (patch)
treec1127fdcc9a66d4ec1ff65ab465f1d3c5fe415f4 /maven-plugins
parente4143e57cd14ca5aa5c92b5a8b5ee8fd7d6342f2 (diff)
TUSCANY-3457 - add temp code to copy the manifest file byte for byte to get round the problem of the copy via the Manifest object dropping some attributes.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@906492 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'maven-plugins')
-rw-r--r--maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java60
1 files changed, 54 insertions, 6 deletions
diff --git a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java
index 4b9198b741..0ab47f4ef4 100644
--- a/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java
+++ b/maven-plugins/trunk/maven-bundle-plugin/src/main/java/org/apache/tuscany/maven/bundle/plugin/ModuleBundlesBuildMojo.java
@@ -649,6 +649,10 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
// Create a bundle directory for a non-OSGi JAR
log.info("Adding JAR artifact: " + artifact);
+ // create manifest directory
+ File file = new File(dir, "META-INF");
+ file.mkdirs();
+
String symbolicName = null;
if (customizedMF == null) {
String version = BundleUtil.osgiVersion(artifact.getVersion());
@@ -664,6 +668,12 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
null,
this.eclipseBuddyPolicy,
this.executionEnvironment);
+
+ file = new File(file, "MANIFEST.MF");
+ FileOutputStream fos = new FileOutputStream(file);
+ write(mf, fos);
+ fos.close();
+ log.info("Writing generated manifest for: " + artifact + " to " + file);
} else {
mf = customizedMF;
symbolicName = BundleUtil.getBundleSymbolicName(mf);
@@ -671,14 +681,35 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
throw new MojoExecutionException("Invalid customized MANIFEST.MF for " + artifact);
}
setBundleClassPath(mf, artifactFile);
+
+ // re-find the custom MF file and copy it
+ // I can't get the manifest file from the manifest itself
+ // the Manifest read/write operation seems to be filtering
+ // out some entries that I've added manually????
+ File artifactManifest = null;
+
+ if (artifactManifests != null) {
+ for (ArtifactManifest m : artifactManifests) {
+ if (m.matches(artifact)) {
+ artifactManifest = m.getManifestFile();
+ break;
+ }
+ }
+ }
+
+ file = new File(file, "MANIFEST.MF");
+
+ if (artifactManifest != null){
+ log.info("Copying: " + artifactManifest + " to " + file);
+ copyManifest(artifactManifest, file);
+ } else {
+ FileOutputStream fos = new FileOutputStream(file);
+ write(mf, fos);
+ fos.close();
+ log.info("Writing generated manifest for: " + artifact + " to " + file);
+ }
}
- File file = new File(dir, "META-INF");
- file.mkdirs();
- file = new File(file, "MANIFEST.MF");
- FileOutputStream fos = new FileOutputStream(file);
- write(mf, fos);
- fos.close();
copyFile(artifactFile, dir);
bundleSymbolicNames.add(artifact, symbolicName);
bundleLocations.add(artifact, dir.getName());
@@ -722,6 +753,7 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
FileOutputStream fos = new FileOutputStream(file);
write(mf, fos);
fos.close();
+ log.info("Written aggregate manifest");
bundleSymbolicNames.add(artifact, symbolicName);
bundleLocations.add(artifact, dir.getName());
if (isServiceProvider(mf)) {
@@ -1167,6 +1199,22 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
out.close();
}
+ private static void copyManifest(File mfFrom, File mfTo) throws FileNotFoundException, IOException {
+ byte[] buf = new byte[4096];
+ FileInputStream in = new FileInputStream(mfFrom);
+ FileOutputStream out = new FileOutputStream(mfTo);
+ for (;;) {
+ int len = in.read(buf);
+ if (len > 0) {
+ out.write(buf, 0, len);
+ } else {
+ break;
+ }
+ }
+ in.close();
+ out.close();
+ }
+
private static void addFileToJar(JarOutputStream out, String entryName, URL file) throws FileNotFoundException,
IOException {
byte[] buf = new byte[4096];