Repository navigation
FELIX-6857 maven-bundle-plugin: do not embed type=pom dependencies - #549
Merged
Merged
Conversation
When a bundle uses Embed-Dependency and a selected dependency is a type=pom artifact (a BOM/aggregator declared as a compile dependency), DependencyEmbedder added that artifact's .pom file to the bundle classpath (Bundle-ClassPath / -includeresource). bnd's CDI-annotations analyzer then tries to open the .pom as a JAR: a warning on bnd 7.0.0 (plugin 6.0.2) but a fatal error on bnd 7.3.0 (plugin 6.1.0), so upgrading the plugin broke any such bundle. A pom contains no classes and must never be placed on the bundle classpath. Skip type=pom artifacts in DependencyEmbedder (covering both the embed and inline paths) with a warning. The non-embed classpath path in BundlePlugin.getClasspath() already excludes poms via ArtifactHandler.isAddedToClasspath(), so only the embed path needed the guard. Adds a BundlePluginTest unit test asserting poms are excluded from Bundle-ClassPath / Embedded-Artifacts, and an embed-pom-dependency integration test that fails without the fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/FELIX-6857
Problem
When a bundle uses
Embed-Dependencyand one of the selected dependencies is atype=pomartifact (a BOM/aggregator declared as a compile dependency),DependencyEmbedderadds that artifact's.pomfile to the bundle classpath(
Bundle-ClassPath/-includeresource). bnd's CDI-annotations analyzer then triesto open the
.pomas a JAR/ZIP and fails:[WARNING] Invalid bundle classpath entryand builds successfully.[ERROR] Error(s) found in bundle configurationand fails the build.So upgrading the plugin breaks any bundle that embeds a pom-type dependency.
The
.pomis valid XML, not corrupt — bnd is simply being handed a pom to open as anarchive.
Root cause
DependencyEmbedderembeds any selected artifact whose file exists, without checkingits type, so a
type=pomdependency's.pomfile ends up on the classpath. A pomcontains no classes and must never be on the bundle classpath.
The underlying hard-fail is a bnd 7.0.0 → 7.3.0 behaviour change in
aQute.bnd.cdi.CDIAnnotations#analyzeJar(a warning promoted to a fatal error), but theplugin should never have placed the
.pomthere in the first place.Fix
Skip
type=pomartifacts inDependencyEmbedder, covering both the embed and inlinepaths, logging a warning so it is not silent. The non-embed classpath path in
BundlePlugin.getClasspath()already excludes poms viaArtifactHandler.isAddedToClasspath(), so only the embed path needed the guard.Reproducer
<Embed-Dependency>*;scope=compile</Embed-Dependency>mvn clean package fails on 6.1.0, succeeds on 6.0.2 (and with this fix).
Testing
Added BundlePluginTest#testEmbedDependencyExcludesPomArtifacts, asserting a pom
dependency is excluded from Bundle-ClassPath and Embedded-Artifacts while a
regular jar is still embedded. Fails without the fix, passes with it.
Added an embed-pom-dependency integration test (a type=pom dependency alongside a
jar dependency). The build fails without the fix (the CDIAnnotations error above) and
passes with it.