FELIX-620: update manifest goal to be compatible with the bundle goal

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@674479 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 4b2d2ef..2db563b 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -362,7 +362,9 @@
         // update BND instructions to add included Maven resources
         includeMavenResources( currentProject, properties, getLog() );
 
-        if ( !properties.containsKey( Analyzer.EXPORT_PACKAGE ) && !properties.containsKey( Analyzer.PRIVATE_PACKAGE ) )
+        if ( !properties.containsKey( Analyzer.EXPORT_PACKAGE ) &&
+             !properties.containsKey( Analyzer.EXPORT_CONTENTS ) &&
+             !properties.containsKey( Analyzer.PRIVATE_PACKAGE ) )
         {
             String bsn = properties.getProperty( Analyzer.BUNDLE_SYMBOLICNAME );
             String namespace = bsn.replaceAll( "\\W", "." );
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 be94f18..b461d83 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -23,6 +23,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -95,14 +96,15 @@
     }
 
 
-    public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException, MojoFailureException
+    public Manifest getManifest( MavenProject project, Jar[] classpath )
+        throws IOException, MojoFailureException, MojoExecutionException
     {
         return getManifest( project, new Properties(), new Properties(), classpath );
     }
 
 
     public Manifest getManifest( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
-        throws IOException, MojoFailureException
+        throws IOException, MojoFailureException, MojoExecutionException
     {
         Analyzer analyzer = getAnalyzer( project, instructions, properties, classpath );
 
@@ -133,29 +135,16 @@
     }
 
 
-    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException
+    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath )
+        throws IOException, MojoExecutionException
     {
         return getAnalyzer( project, new HashMap(), new Properties(), classpath );
     }
 
 
     protected Analyzer getAnalyzer( MavenProject project, Map instructions, Properties properties, Jar[] classpath )
-        throws IOException
+        throws IOException, MojoExecutionException
     {
-        PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
-
-        Properties props = getDefaultProperties( project );
-        props.putAll( properties );
-
-        if ( !instructions.containsKey( Analyzer.IMPORT_PACKAGE ) )
-        {
-            props.put( Analyzer.IMPORT_PACKAGE, "*" );
-        }
-
-        props.putAll( transformDirectives( instructions ) );
-
-        analyzer.setProperties( props );
-
         File file = project.getArtifact().getFile();
         if ( file == null )
         {
@@ -167,20 +156,33 @@
             throw new FileNotFoundException( file.getPath() );
         }
 
-        analyzer.setJar( file );
+        properties.putAll( getDefaultProperties( project ) );
+        properties.putAll( transformDirectives( instructions ) );
+
+        PackageVersionAnalyzer analyzer = new PackageVersionAnalyzer();
+        analyzer.setProperties( properties );
+
+        if ( project.getBasedir() != null )
+            analyzer.setBase( project.getBasedir() );
 
         if ( classpath != null )
             analyzer.setClasspath( classpath );
 
-        if ( !instructions.containsKey( Analyzer.PRIVATE_PACKAGE )
-            && !instructions.containsKey( Analyzer.EXPORT_PACKAGE ) )
+        analyzer.setJar( file );
+
+        if ( !properties.containsKey( Analyzer.EXPORT_PACKAGE ) &&
+             !properties.containsKey( Analyzer.EXPORT_CONTENTS ) &&
+             !properties.containsKey( Analyzer.PRIVATE_PACKAGE ) )
         {
             String export = analyzer.calculateExportsFromContents( analyzer.getJar() );
             analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
         }
 
-        analyzer.mergeManifest( analyzer.getJar().getManifest() );
+        // Apply Embed-Dependency headers, even though the contents won't be changed
+        Collection embeddableArtifacts = getEmbeddableArtifacts( project, properties );
+        new DependencyEmbedder( embeddableArtifacts ).processHeaders( properties );
 
+        analyzer.mergeManifest( analyzer.getJar().getManifest() );
         analyzer.calcManifest();
 
         return analyzer;