Skip to content

Handle bnd SNAPSHOT version-mismatch warnings centrally in the parent pom#26055

Open
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:fix-issue-26004-grizzly-extra-all-osgi-version
Open

Handle bnd SNAPSHOT version-mismatch warnings centrally in the parent pom#26055
renatsaf wants to merge 1 commit into
eclipse-ee4j:mainfrom
renatsaf:fix-issue-26004-grizzly-extra-all-osgi-version

Conversation

@renatsaf

@renatsaf renatsaf commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@

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:

Version for package org.glassfish.grizzly.comet is set to different values in the
source (5.0.2-SNAPSHOT) and in the manifest (5.0.2) ...

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)

  • maven-bundle-plugin: a _fixupmessages instruction promotes that specific 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 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-property steps with a fresh property, because regex-property does not overwrite an already-set property — a predefined error default would never be relaxed to ignore (verified).

Verification

Built glassfish-grizzly-extra-all (unchanged, still using explicit ${grizzly.version} / ${project.version} exports) against the patched parent:

  • mvn packageBUILD SUCCESS, 0 "Version for package" warnings.
  • Manifest keeps valid OSGi versions, e.g. org.glassfish.extras.grizzly;version="8.0.3.SNAPSHOT".

Fixes #26004

🤖 Generated with Claude Code
@

@OndroMih

OndroMih commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

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>
@renatsaf renatsaf force-pushed the fix-issue-26004-grizzly-extra-all-osgi-version branch from c3a7e0d to 8eb7a73 Compare June 5, 2026 19:22
@renatsaf renatsaf changed the title Fix glassfish-grizzly-extra-all invalid OSGi manifest versions Handle bnd SNAPSHOT version-mismatch warnings centrally in the parent pom Jun 5, 2026
@renatsaf

renatsaf commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

@
Pivoted this PR to @OndroMihs parent-pom approach instead of the per-module version change. It now fixes the whole class of warnings centrally in nucleus/parent/pom.xml, and adds the release-time guard (level error for releases, ignore for SNAPSHOTs).

One fix to the snippet: regex-property does not overwrite an already-set property, so a predefined error default never gets relaxed to ignore. I compute the level in two regex-property steps with a fresh property instead. Verified that SNAPSHOT builds now emit zero warnings and the manifest keeps valid OSGi versions.
@

@dmatej

dmatej commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

I noted it WAS not that it IS a problem. Current Felix plugin resolves that correctly.
Interesting solution, maybe good direction, however I dislike that it would behave differently just in the release build. That is too late. It must fail as soon as possible.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The glassfish-grizzly-extra-all produces invalid manifest headers

3 participants