FELIX-3254: automatically rebuild bundle in-memory when using manifest goal with target/classes and Embed-Dependency

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1243117 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 9f0e892..c0f3c2b 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -183,10 +183,11 @@
         // the contents of the bundle *and* we are not analyzing the output directory,
         // otherwise fall-back to addMavenInstructions approach
 
+        boolean isOutputDirectory = file.equals( getOutputDirectory() );
+
         if ( analyzer.getProperty( Analyzer.EXPORT_PACKAGE ) == null
             && analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null
-            && analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null
-            && !file.equals( getOutputDirectory() ) )
+            && analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null && !isOutputDirectory )
         {
             String export = calculateExportsFromContents( analyzer.getJar() );
             analyzer.setProperty( Analyzer.EXPORT_PACKAGE, export );
@@ -194,8 +195,16 @@
 
         addMavenInstructions( project, analyzer );
 
-        analyzer.mergeManifest( analyzer.getJar().getManifest() );
-        analyzer.calcManifest();
+        // if we spot Embed-Dependency and the bundle is "target/classes", assume we need to rebuild
+        if ( analyzer.getProperty( DependencyEmbedder.EMBED_DEPENDENCY ) != null && isOutputDirectory )
+        {
+            analyzer.build();
+        }
+        else
+        {
+            analyzer.mergeManifest( analyzer.getJar().getManifest() );
+            analyzer.calcManifest();
+        }
 
         mergeMavenManifest( project, analyzer );