[FELIX-2701] Add a {local-packages} macro for automatically expanding local packages in the <Export-Package> instruction

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1035946 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 756064a..1804210 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -186,6 +186,7 @@
 
     private static final String MAVEN_SYMBOLICNAME = "maven-symbolicname";
     private static final String MAVEN_RESOURCES = "{maven-resources}";
+    private static final String LOCAL_PACKAGES = "{local-packages}";
 
     private static final String[] EMPTY_STRING_ARRAY =
         {};
@@ -378,11 +379,7 @@
         includeMavenResources( currentProject, builder, getLog() );
 
         // calculate default export/private settings based on sources
-        if ( builder.getProperty( Analyzer.PRIVATE_PACKAGE ) == null
-            || builder.getProperty( Analyzer.EXPORT_PACKAGE ) == null )
-        {
-            addLocalPackages( currentProject.getCompileSourceRoots(), builder );
-        }
+        addLocalPackages( currentProject.getCompileSourceRoots(), builder );
 
         // update BND instructions to embed selected Maven dependencies
         Collection embeddableArtifacts = getEmbeddableArtifacts( currentProject, builder );
@@ -955,7 +952,11 @@
             // we can't export the default package (".") and we shouldn't export internal packages 
             if ( !( ".".equals( pkg ) || pkg.contains( ".internal" ) || pkg.contains( ".impl" ) ) )
             {
-                exportedPkgs.append( pkg ).append( ',' );
+                if( exportedPkgs.length() > 0 )
+                {
+                    exportedPkgs.append( ';' );
+                }
+                exportedPkgs.append( pkg );
             }
         }
 
@@ -972,6 +973,16 @@
                 analyzer.setProperty( Analyzer.EXPORT_PACKAGE, "" );
             }
         }
+        else
+        {
+            String exported = analyzer.getProperty( Analyzer.EXPORT_PACKAGE );
+            if( exported.indexOf( LOCAL_PACKAGES ) >= 0 )
+            {
+                String newExported = StringUtils.replace( exported, LOCAL_PACKAGES, exportedPkgs.toString() );
+                analyzer.setProperty( Analyzer.EXPORT_PACKAGE, newExported );
+
+            }
+        }
 
         if ( analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
         {