FELIX-461: Ensure bundle:manifest goal creates same manifest when project packaging is bundle

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@616677 13f79535-47bb-0310-9956-ffa450edef68
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 56ef91c..1cdc6dc 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -50,7 +50,14 @@
         Manifest manifest;
         try
         {
-            manifest = getManifest( project, instructions, properties, classpath );
+            if ( "bundle".equals( project.getPackaging() ) )
+            {
+                manifest = buildOSGiBundle( project, instructions, properties, classpath ).getJar().getManifest();
+            }
+            else
+            {
+                manifest = getManifest( project, instructions, properties, classpath );
+            }
         }
         catch ( FileNotFoundException e )
         {
@@ -61,6 +68,11 @@
         {
             throw new MojoExecutionException( "Error trying to generate Manifest", e );
         }
+        catch ( Exception e )
+        {
+            getLog().error( "An internal error occurred", e );
+            throw new MojoExecutionException( "Internal error in maven-bundle-plugin", e );
+        }
 
         File outputFile = new File( manifestLocation, "MANIFEST.MF" );