Author: mcculls
Date: Fri Sep 21 04:18:31 2007
New Revision: 578067

URL: http://svn.apache.org/viewvc?rev=578067&view=rev
Log:
FELIX-376: Support writing of manifest to the file system when using bundle goal

Modified:
    
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.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=578067&r1=578066&r2=578067&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
 Fri Sep 21 04:18:31 2007
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.jar.Manifest;
 import java.util.zip.ZipException;
 
 import org.apache.maven.artifact.Artifact;
@@ -60,6 +61,13 @@
 public class BundlePlugin extends AbstractMojo {
 
     /**
+     * Directory where the manifest will be written
+     * 
+     * @parameter expression="${manifestLocation}" 
default-value="${project.build.outputDirectory}/META-INF"
+     */
+    protected String manifestLocation;
+
+    /**
      * @component
      */
     private ArtifactHandlerManager artifactHandlerManager;
@@ -274,15 +282,30 @@
                 Artifact bundleArtifact = project.getArtifact();
                 bundleArtifact.setFile(jarFile);
 
+                if (manifestLocation != null && manifestLocation.length() > 0)
+                {
+                    File outputFile = new File( manifestLocation, 
"MANIFEST.MF" );
+
+                    try
+                    {
+                        Manifest manifest = builder.getJar().getManifest();
+                        ManifestPlugin.writeManifest( manifest, outputFile );
+                    }
+                    catch ( IOException e )
+                    {
+                        getLog().error( "Error trying to write Manifest to 
file " + outputFile, e );
+                    }
+                }
+                
                 // workaround for MNG-1682: force maven to install artifact 
using the "jar" handler
                 bundleArtifact.setArtifactHandler( 
artifactHandlerManager.getArtifactHandler( "jar" ) );
             }
+
             for (Iterator w = warnings.iterator(); w.hasNext();)
             {
                 String msg = (String) w.next();
                 this.getLog().warn("Warning building bundle " + 
project.getArtifact() + " : " + msg);
             }
-
         }
         catch (Exception e)
         {

Modified: 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java?rev=578067&r1=578066&r2=578067&view=diff
==============================================================================
--- 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
 (original)
+++ 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
 Fri Sep 21 04:18:31 2007
@@ -43,13 +43,6 @@
 public class ManifestPlugin
     extends BundlePlugin
 {
-
-    /**
-     * Directory where the manifest will be written
-     * @parameter expression="${project.build.outputDirectory}/META-INF"
-     */
-    private String manifestLocation;
-
     protected void execute( MavenProject project, Map instructions, Properties 
properties, Jar[] classpath )
         throws MojoExecutionException
     {
@@ -71,7 +64,7 @@
 
         try
         {
-            this.writeManifest( manifest, outputFile );
+            writeManifest( manifest, outputFile );
         }
         catch ( IOException e )
         {
@@ -144,7 +137,7 @@
         return analyzer;
     }
 
-    public void writeManifest( Manifest manifest, File outputFile )
+    public static void writeManifest( Manifest manifest, File outputFile )
         throws IOException
     {
         outputFile.getParentFile().mkdirs();


Reply via email to