Skip to content

build: add OSGi support to all deployable modules (#1477) - #5011

Merged
jlerbsc merged 1 commit into
javaparser:masterfrom
ethan-godden:issue-1477-improve-osgi-support
May 14, 2026
Merged

jlerbsc merged 1 commit into
javaparser:masterfrom
ethan-godden:issue-1477-improve-osgi-support

Conversation

@ethan-godden

@ethan-godden ethan-godden commented May 7, 2026 •

Copy link
Copy Markdown

Closes #1477.

Adds OSGi metadata to all published modules automatically by wiring bnd-maven-plugin into the parent POM. Each module's jar now exposes Bundle-SymbolicName, Bundle-Version, and appropriate Export-Package / Import-Package headers, so the artifacts can be dropped into Felix/Equinox without repackaging.
Verification

mvn clean install succeeds; generated MANIFEST.MF inspected for each module.
Loaded javaparser-core jar into a OSGi project to confirm the bundle resolves.
No changes to non-OSGi Maven/Gradle consumers β€” same coordinates, same classes.

Future work (not in this PR)
P2 repository / Eclipse RCP (Equinox) support would require either consumers building from source or hosting an Eclipse update site β€” happy to open a separate issue if there's interest.

@ethan-godden ethan-godden changed the title build(javaparser-1477): OSGi support build: add OSGi support to all modules (#1477) May 8, 2026
@jlerbsc

jlerbsc commented May 11, 2026

Copy link
Copy Markdown
Collaborator

It seems to me that this press release is lacking in explanation. For example, could you explain why you are removing the generator...

@ethan-godden

ethan-godden commented May 11, 2026 •

Copy link
Copy Markdown
Author

@jlerbsc

It seems to me that this press release is lacking in explanation. For example, could you explain why you are removing the generator...

  • The purpose of BndGenerator was to generate the bnd.bnd file: a file used by the BND plugin to generate the OSGi MANIFEST.MF
  • The bnd.bnd file is not needed anymore because its now defined concisely in the parent pom.xml file.
<configuration>
    <!--
        Bundle-SymbolicName is derived from groupId + artifactId. OSGi permits
        dashes here, so this preserves names like
        `com.github.javaparser.javaparser-core` for OSGi consumers.
    
        Automatic-Module-Name uses ${jpms.moduleName} because JPMS module names
        disallow dashes β€” each module sets this property to a dot-separated,
        dash-free identifier.
    -->
    <bnd><![CDATA[
        Bundle-SymbolicName: ${project.groupId}.${project.artifactId}
        Automatic-Module-Name: ${jpms.moduleName}
        -exportcontents: ${osgi.export}
        -nodefaultversion: true
        Bundle-DocURL: https://javaparser.org
    ]]></bnd>
</configuration>
  • Previously, the BND plugin required packages to be declared explicitly in the -exportcontents: section, but it now allows for wildcards, which is defined as a property here. OSGi wildcards are sometimes are frowned upon because you are possibly exporting implementation classes users do not need. However, BndGenerator does not seem to filter out any packages, so this is functionally equivalent to what it was before.
  • In the generated MANIFEST.MF, the packages are declared explicitly based on the pattern passed
  • Even when configuration of explicit exports are needed, we could just define them via the osgi.export maven property with syntax similar to how the MANIFEST.MF is defined above, which I believe is simpler that the BndGenerator approach

@jlerbsc

jlerbsc commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Why are you including the test projects in this PR? What added value do these projects bring to OSGi?

@codecov

codecov Bot commented May 12, 2026 •

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 58.711%. Comparing base (d75a888) to head (b4e443b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##              master     #5011   +/-   ##
===========================================
  Coverage     58.711%   58.711%           
  Complexity      2592      2592           
===========================================
  Files            702       702           
  Lines          40217     40217           
  Branches        7327      7327           
===========================================
  Hits           23612     23612           
  Misses         13634     13634           
  Partials        2971      2971           
Flag Coverage Ξ”
AlsoSlowTests 58.711% <ΓΈ> (ΓΈ)
javaparser-core 58.711% <ΓΈ> (ΓΈ)
javaparser-symbol-solver 58.711% <ΓΈ> (ΓΈ)
jdk-10 58.281% <ΓΈ> (-0.003%) ⬇️
jdk-11 58.283% <ΓΈ> (ΓΈ)
jdk-12 58.280% <ΓΈ> (ΓΈ)
jdk-13 58.283% <ΓΈ> (ΓΈ)
jdk-14 58.511% <ΓΈ> (-0.003%) ⬇️
jdk-15 58.514% <ΓΈ> (ΓΈ)
jdk-16 58.489% <ΓΈ> (ΓΈ)
jdk-17 58.638% <ΓΈ> (ΓΈ)
jdk-18 58.636% <ΓΈ> (-0.003%) ⬇️
jdk-8 58.120% <ΓΈ> (ΓΈ)
jdk-9 58.281% <ΓΈ> (+0.002%) ⬆️
macos-latest 58.686% <ΓΈ> (ΓΈ)
ubuntu-latest 58.681% <ΓΈ> (ΓΈ)
windows-latest 58.694% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 9ba7e45...b4e443b. Read the comment docs.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ethan-godden

ethan-godden commented May 12, 2026 •

Copy link
Copy Markdown
Author

Why are you including the test projects in this PR? What added value do these projects bring to OSGi?

@jlerbsc

There is no added value. I included them because it reduces the added build complexity of this PR with a negligible performance hit to the build. If a new module is added to this project, the only OSGi configuration needed would be to define jpms.moduleName without dashes. We could even define a default jpms.moduleName as ${project.groupId}.${project.artifactId} in the parent to avoid this.

I have commited a fix (ced4bfe) regarding this. I had to add configurations per deployable module. Any new module would also need this.

@jlerbsc

jlerbsc commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Could you please squash your commits to make the PR easier to read? Thank you.

@ethan-godden
ethan-godden force-pushed the issue-1477-improve-osgi-support branch from ced4bfe to d248dac Compare May 14, 2026 00:12
@ethan-godden

Copy link
Copy Markdown
Author

Could you please squash your commits to make the PR easier to read? Thank you.

@jlerbsc Done

@ethan-godden
ethan-godden force-pushed the issue-1477-improve-osgi-support branch from d248dac to 2c691f7 Compare May 14, 2026 00:23
@ethan-godden
ethan-godden force-pushed the issue-1477-improve-osgi-support branch from 2c691f7 to b4e443b Compare May 14, 2026 00:32
@ethan-godden ethan-godden changed the title build: add OSGi support to all modules (#1477) build: add OSGi support to all deployable modules (#1477) May 14, 2026
@jlerbsc

jlerbsc commented May 14, 2026

Copy link
Copy Markdown
Collaborator

"Future work (not in this PR)
P2 repository / Eclipse RCP (Equinox) support would require either consumers building from source or hosting an Eclipse update site β€” happy to open a separate issue if there's interest."

There is no need to submit this pull request, as JP is not intended to provide features for other projects. However, you could create a separate project specifically designed to provide these user-friendly features.

@jlerbsc
jlerbsc merged commit cb829f5 into javaparser:master May 14, 2026
35 checks passed
@jlerbsc

jlerbsc commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Thank you for this PR.

@jlerbsc jlerbsc added this to the next release milestone May 14, 2026
@jlerbsc jlerbsc added the PR: Changed A PR that changes implementation without changing behaviour (e.g. performance) label May 14, 2026
@ethan-godden
ethan-godden deleted the issue-1477-improve-osgi-support branch May 14, 2026 08:11
@ethan-godden

Copy link
Copy Markdown
Author

@jlerbsc I noticed that the changes made in this PR seem to have been reverted in this commit. Was this intentional?

@jlerbsc

jlerbsc commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Hi @ethan-godden β€” while reviewing recent history I found that PR #5011 (OSGi support, #1477) was accidentally reverted five days after it was merged: PR #5019 was based on a stale master and its commit unintentionally restored the old build files (BndGenerator, bnd.bnd, and the previous pom configuration). As a result, the OSGi improvements never shipped in 3.28.2, even though #1477 was closed as completed.

I’m going to draft a PR that will restore the original commit as-is (clean cherry-pick of b4e443b, original authorship preserved). I verified the build and confirmed the generated MANIFEST.MF contains the expected Bundle-SymbolicName, Bundle-Version, Export-Package, and Automatic-Module-Name headers. Apologies to @ethan-godden for the accidental revert β€” the fix will be included in the next release.

jlerbsc added a commit that referenced this pull request Jul 19, 2026
PR #5011 added OSGi support to all deployable modules (#1477), but was accidentally
reverted five days later by #5019, whose branch was based on a stale master and
unintentionally restored the old build files. As a result, 3.28.2 shipped without it.

This PR restores the original commit as-is (clean cherry-pick of `b4e443b`,
@ethan-godden's authorship preserved).

Verified: build passes and the resulting jar's `MANIFEST.MF` contains the expected
`Bundle-SymbolicName`, `Bundle-Version`, `Export-Package` and `Automatic-Module-Name`
headers. Apologies to @ethan-godden β€” this will be included in the next release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Changed A PR that changes implementation without changing behaviour (e.g. performance)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improving OSGI support

2 participants