Handle bnd SNAPSHOT version-mismatch warnings centrally in the parent pom#26055
Handle bnd SNAPSHOT version-mismatch warnings centrally in the parent pom#26055renatsaf wants to merge 1 commit into
Conversation
|
I would rather implement solution that I described in #26004 (comment) - it keeps the current behavior and cleans up the warnings. Additionally, it fails the build if SNAPSHOTS are used during a release when the project.version is not a SNAPSHOT version, which could save us from issues if we keep a SNAPSHOT dependency. |
Bundle modules export packages whose version is derived from a Maven
SNAPSHOT (e.g. 5.0.2-SNAPSHOT). That is not a valid OSGi version, so bnd
truncates it in the manifest and reports "Version for package ... is set to
different values in the source and in the manifest". This is a known issue
spread across many modules.
Handle it centrally in nucleus/parent instead of per module:
* maven-bundle-plugin: a _fixupmessages instruction promotes that warning to
${bnd.version.mismatch.level}.
* build-helper-maven-plugin: regex-property sets bnd.version.mismatch.level to
'ignore' for -SNAPSHOT builds and 'error' otherwise, so a release build fails
if it would ship a truncated SNAPSHOT-derived package version, while SNAPSHOT
development stays quiet.
The level is computed in two regex-property steps with a fresh property because
regex-property does not overwrite an already-set property (a predefined default
would never be relaxed to 'ignore').
Based on the approach suggested by @OndroMih in the issue.
Fixes eclipse-ee4j#26004
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
c3a7e0d to
8eb7a73
Compare
|
@ One fix to the snippet: |
|
I noted it WAS not that it IS a problem. Current Felix plugin resolves that correctly. Somewhere we used the helper plugin to compute a project.osgi.version which was then used in these osgi headers. The project.version should not be used ever. Then there is yet another trap - some headers use x.y.z-SNAPSHOT and it is alright, the x.y.z.SNAPSHOT must not be just in those imports/exports/... lists. |
@
Problem
Many bundle modules export packages whose version is derived from a Maven SNAPSHOT (e.g.
5.0.2-SNAPSHOT). That is not a valid OSGi version, so bnd truncates it in the manifest and warns:As @dmatej noted, this is a known issue spread across many modules, so a per-module fix is not ideal.
Fix (per @OndroMihs suggestion, applied in
nucleus/parent/pom.xml)_fixupmessagesinstruction promotes that specific warning to${bnd.version.mismatch.level}.regex-propertysetsbnd.version.mismatch.leveltoignorefor-SNAPSHOTbuilds anderrorotherwise — so SNAPSHOT development stays quiet, while a release build fails if it would ship a truncated SNAPSHOT-derived package version.One deviation from the original snippet: the level is computed in two
regex-propertysteps with a fresh property, becauseregex-propertydoes not overwrite an already-set property — a predefinederrordefault would never be relaxed toignore(verified).Verification
Built
glassfish-grizzly-extra-all(unchanged, still using explicit${grizzly.version}/${project.version}exports) against the patched parent:mvn package→ BUILD SUCCESS, 0 "Version for package" warnings.org.glassfish.extras.grizzly;version="8.0.3.SNAPSHOT".Fixes #26004
🤖 Generated with Claude Code
@