FELIX-3238: clean up processing of default Export/Private-Package
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1207213 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 258b7c0..162b773 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -1249,7 +1249,11 @@
String pkg = ( String ) i.next();
// mark all source packages as private by default (can be overridden by export list)
- privatePkgs.append( pkg ).append( ";-split-package:=merge-first," );
+ if ( privatePkgs.length() > 0 )
+ {
+ privatePkgs.append( ';' );
+ }
+ privatePkgs.append( pkg );
// we can't export the default package (".") and we shouldn't export internal packages
if ( noprivatePackages || !( ".".equals( pkg ) || pkg.contains( ".internal" ) || pkg.contains( ".impl" ) ) )
@@ -1267,7 +1271,7 @@
if ( analyzer.getProperty( Analyzer.EXPORT_CONTENTS ) == null )
{
// no -exportcontents overriding the exports, so use our computed list
- analyzer.setProperty( Analyzer.EXPORT_PACKAGE, exportedPkgs.toString() );
+ analyzer.setProperty( Analyzer.EXPORT_PACKAGE, exportedPkgs + ";-split-package:=merge-first" );
}
else
{
@@ -1286,10 +1290,23 @@
}
}
- if ( analyzer.getProperty( Analyzer.PRIVATE_PACKAGE ) == null )
+ String internal = analyzer.getProperty( Analyzer.PRIVATE_PACKAGE );
+ if ( internal == null )
{
- // if there are really no private packages then use "!*" as this will keep the Bnd Tool happy
- analyzer.setProperty( Analyzer.PRIVATE_PACKAGE, privatePkgs.length() == 0 ? "!*" : privatePkgs.toString() );
+ if ( privatePkgs.length() > 0 )
+ {
+ analyzer.setProperty( Analyzer.PRIVATE_PACKAGE, privatePkgs + ";-split-package:=merge-first" );
+ }
+ else
+ {
+ // if there are really no private packages then use "!*" as this will keep the Bnd Tool happy
+ analyzer.setProperty( Analyzer.PRIVATE_PACKAGE, "!*" );
+ }
+ }
+ else if ( internal.indexOf( LOCAL_PACKAGES ) >= 0 )
+ {
+ String newInternal = StringUtils.replace( internal, LOCAL_PACKAGES, privatePkgs.toString() );
+ analyzer.setProperty( Analyzer.PRIVATE_PACKAGE, newInternal );
}
}