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

build: add OSGi support to all deployable modules (#1477)#5011
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
Contributor

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
Contributor 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
Contributor 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
Contributor 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
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