3131
3232import java .io .File ;
3333import java .io .IOException ;
34+ import java .util .Arrays ;
3435import java .util .jar .Attributes ;
3536import java .util .jar .Manifest ;
3637
@@ -63,6 +64,7 @@ public AquteBundler(boolean pedantic, boolean ignoreBndErrors) {
6364 this .pedantic = pedantic ;
6465 }
6566
67+ @ Override
6668 public void execute (ArtifactBundlerRequest request , ArtifactBundlerInstructions instructions ) {
6769 log ().info ("Executing Bundler:" );
6870 try {
@@ -173,6 +175,7 @@ private Manifest getManifest(Jar jar) throws Exception {
173175 }
174176
175177 private void decorateSourceManifest (Manifest manifest , String name , String refrencedBundleSymbolicName , String symbolicName , String version ) {
178+ sanitizeSourceManifest (manifest );
176179 Attributes attributes = manifest .getMainAttributes ();
177180 attributes .putValue (Analyzer .BUNDLE_SYMBOLICNAME , symbolicName );
178181 attributes .putValue (ECLIPSE_SOURCE_BUNDLE , refrencedBundleSymbolicName + ";version=\" " + version + "\" ;roots:=\" .\" " );
@@ -186,6 +189,19 @@ private void decorateSourceManifest(Manifest manifest, String name, String refre
186189 attributes .putValue (AquteHelper .TOOL_KEY , AquteHelper .TOOL );
187190 }
188191
192+ /**
193+ * Removes the bundle manifest headers that incorrectly cause a source bundle being
194+ * resolved instead of its corresponding classes bundle.
195+ */
196+ private void sanitizeSourceManifest (Manifest manifest ) {
197+ Attributes attributes = manifest .getMainAttributes ();
198+ if (!attributes .isEmpty ()) {
199+ // note that header is of type Attributes.Name, hence we call header.toString()
200+ attributes .keySet ().removeIf (header -> Arrays .asList (Analyzer .EXPORT_PACKAGE ,
201+ Analyzer .EXPORT_SERVICE , Analyzer .PROVIDE_CAPABILITY ).contains (header .toString ()));
202+ }
203+ }
204+
189205 private Logger log () {
190206 return Logger .getLog ();
191207 }
0 commit comments