Make sure directory exists before writing manifest; include support for niceManifest in manifest goal

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1604766 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 7c4145b..14d745f 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -101,6 +101,13 @@
     protected File manifestLocation;
 
     /**
+     * Output a nicely formatted manifest that still respects the 72 character line limit.
+     *
+     * @parameter expression="${niceManifest}" default-value="false"
+     */
+    protected boolean niceManifest;
+
+    /**
      * File where the BND instructions will be dumped
      *
      * @parameter expression="${dumpInstructions}"
@@ -225,13 +232,6 @@
      */
     private MavenSession m_mavenSession;
 
-    /**
-     * Output a nicely formatted manifest that still respects the 72 character line limit.
-     *
-     * @parameter
-     */
-    private boolean niceManifest = false;
-
     private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
     private static final String MAVEN_RESOURCES = "{maven-resources}";
     private static final String MAVEN_TEST_RESOURCES = "{maven-test-resources}";
@@ -430,15 +430,7 @@
                 try
                 {
                     Manifest manifest = builder.getJar().getManifest();
-                    FileOutputStream fos = new FileOutputStream( outputFile );
-                    try
-                    {
-                        ManifestWriter.outputManifest( manifest, fos, niceManifest );
-                    }
-                    finally
-                    {
-                        fos.close();
-                    }
+                    ManifestPlugin.writeManifest( manifest, outputFile, niceManifest );
                 }
                 catch ( IOException e )
                 {
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index 2c2d718..4bac2ab 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -92,7 +92,7 @@
 
         try
         {
-            writeManifest( manifest, outputFile );
+            writeManifest( manifest, outputFile, niceManifest );
         }
         catch ( IOException e )
         {
@@ -219,7 +219,7 @@
     }
 
 
-    public static void writeManifest( Manifest manifest, File outputFile ) throws IOException
+    public static void writeManifest( Manifest manifest, File outputFile, boolean niceManifest ) throws IOException
     {
         outputFile.getParentFile().mkdirs();
 
@@ -227,7 +227,7 @@
         os = new FileOutputStream( outputFile );
         try
         {
-            Jar.writeManifest( manifest, os );
+            ManifestWriter.outputManifest( manifest, os, niceManifest );
         }
         finally
         {