Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add osgi headers via maven-bundle-plugin #359

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zspitzer
Copy link

@zspitzer zspitzer commented Jan 19, 2025

following up on #128

this PR adds the maven-bundle-plugin and config

I am doing this, as we use Commonmark in Lucee, for the initial version, we wrapped the jar ourselves with OSGI metadata, but now I'd like to add some extensions and I'd rather just use commonmark jars

lucee/Lucee#2473

I have tested this locally and the OSGI Export-Package / Import-Package headers look good

But there are some warnings be thrown for each extension

[INFO] --- bundle:6.0.0:bundle (bundle) @ commonmark-ext-autolink ---
[WARNING] Bundle org.commonmark:commonmark-ext-autolink:jar:0.24.1-SNAPSHOT : Split package, multiple jars provide the same package:
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid of this warning
Package found in   [Jar:., Jar:commonmark, Jar:autolink]
Class path         [Jar:., Jar:commonmark, Jar:autolink]
[INFO] Building bundle: D:\work\java\commonmark-java\commonmark-ext-autolink\target\commonmark-ext-autolink-0.24.1-SNAPSHOT.jar
[INFO] Writing manifest: D:\work\java\commonmark-java\commonmark-ext-autolink\target\classes\META-INF\MANIFEST.MF

In addition, the autolink dependancy also needs OSGI metadata

<artifactId>maven-bundle-plugin</artifactId>
</plugin>
</plugins>
</build>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to only put this into the <build><plugins> of the parent pom instead of every child pom (I'm not sure if that works or not)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only way I could get it working, been a few months since I put this together, so I can't exactly remember variations I tried.

I'll revisit it and let you know what I find

</Import-Package>
<Export-Package>
{local-packages}
</Export-Package>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this export internal packages? If yes, can we prevent them from being exported?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the file MANIFEST is produces

Manifest-Version: 1.0
Bnd-LastModified: 1737245630605
Build-Jdk-Spec: 21
Bundle-Description: Core of commonmark-java (a library for parsing Mar
 kdown to an AST, modifying the AST and rendering it to HTML or Markdo
 wn)
Bundle-License: https://opensource.org/licenses/BSD-2-Clause
Bundle-ManifestVersion: 2
Bundle-Name: commonmark-java core
Bundle-SymbolicName: org.commonmark
Bundle-Version: 0.24.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin 6.0.0
Export-Package: org.commonmark;version="0.24.1",org.commonmark.node;ve
 rsion="0.24.1",org.commonmark.parser;version="0.24.1";uses:="org.comm
 onmark,org.commonmark.node,org.commonmark.parser.beta,org.commonmark.
 parser.block,org.commonmark.parser.delimiter",org.commonmark.parser.b
 eta;version="0.24.1";uses:="org.commonmark.node,org.commonmark.parser
 ,org.commonmark.text",org.commonmark.parser.block;version="0.24.1";us
 es:="org.commonmark.node,org.commonmark.parser",org.commonmark.parser
 .delimiter;version="0.24.1";uses:="org.commonmark.node",org.commonmar
 k.renderer;version="0.24.1";uses:="org.commonmark.node",org.commonmar
 k.renderer.html;version="0.24.1";uses:="org.commonmark,org.commonmark
 .node,org.commonmark.renderer",org.commonmark.renderer.markdown;versi
 on="0.24.1";uses:="org.commonmark,org.commonmark.node,org.commonmark.
 renderer,org.commonmark.text",org.commonmark.renderer.text;version="0
 .24.1";uses:="org.commonmark,org.commonmark.node,org.commonmark.rende
 rer",org.commonmark.text;version="0.24.1"
Import-Package: org.commonmark;version="[0.24,1)",org.commonmark.parse
 r.delimiter;version="[0.24,1)",org.commonmark.renderer;version="[0.24
 ,1)",org.commonmark.text;version="[0.24,1)"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=11))"
Tool: Bnd-7.0.0.202310060912

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so looks like there's no internal packages there.

Why does it have an Import-Package?

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.

2 participants