You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2008/01/09 16:21:19 UTC
svn commit: r610415 -
/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Author: mcculls
Date: Wed Jan 9 07:19:32 2008
New Revision: 610415
URL: http://svn.apache.org/viewvc?rev=610415&view=rev
Log:
FELIX-442: handle custom manifest sections and external manifest files
Modified:
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=610415&r1=610414&r2=610415&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java Wed Jan 9 07:19:32 2008
@@ -20,7 +20,9 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,9 +33,11 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.zip.ZipException;
+import org.apache.maven.archiver.ManifestSection;
import org.apache.maven.archiver.MavenArchiveConfiguration;
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
@@ -327,12 +331,47 @@
*/
MavenArchiveConfiguration archiveConfig = JarPluginConfiguration.getArchiveConfiguration( project );
String mavenManifestText = new MavenArchiver().getManifest( project, archiveConfig ).toString();
-
Manifest mavenManifest = new Manifest();
+
+ // First grab the external manifest file (if specified)
+ File externalManifestFile = archiveConfig.getManifestFile();
+ if ( null != externalManifestFile )
+ {
+ InputStream mis = new FileInputStream( externalManifestFile );
+ mavenManifest.read( mis );
+ mis.close();
+ }
+
+ // Then apply the customized entries from the jar plugin
mavenManifest.read( new StringInputStream( mavenManifestText ) );
+ if ( !archiveConfig.isManifestSectionsEmpty() )
+ {
+ /*
+ * Add customized manifest sections (for some reason MavenArchiver doesn't do this for us)
+ */
+ List sections = archiveConfig.getManifestSections();
+ for ( Iterator i = sections.iterator(); i.hasNext(); )
+ {
+ ManifestSection section = (ManifestSection) i.next();
+ Attributes attributes = new Attributes();
+
+ if ( !section.isManifestEntriesEmpty() )
+ {
+ Map entries = section.getManifestEntries();
+ for ( Iterator j = entries.entrySet().iterator(); j.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) j.next();
+ attributes.putValue( (String)entry.getKey(), (String)entry.getValue() );
+ }
+ }
+
+ mavenManifest.getEntries().put( section.getName(), attributes );
+ }
+ }
+
/*
- * Overlay customized Maven manifest with the generated bundle manifest
+ * Overlay generated bundle manifest with customized entries
*/
Manifest bundleManifest = jar.getManifest();
bundleManifest.getMainAttributes().putAll( mavenManifest.getMainAttributes() );