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 metadata to asciidoctorj-core jar #328

Merged
merged 2 commits into from
Jun 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions asciidoctorj-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: 'osgi'

dependencies {
compile "org.jruby:jruby-complete:$jrubyVersion"
compile "com.beust:jcommander:$jcommanderVersion"
Expand Down Expand Up @@ -32,3 +34,19 @@ jrubyPrepareGems << {
//jruby {
// execVersion = '1.7.20'
//}

jar {
manifest {
symbolicName = 'org.asciidoctor'
instruction 'Export-Package',
"org.asciidoctor;version=\"${version}\"",
"org.asciidoctor.ast;version=\"${version}\"",
"org.asciidoctor.converter;version=\"${version}\"",
"org.asciidoctor.converter.spi;version=\"${version}\"",
"org.asciidoctor.extension;version=\"${version}\"",
"org.asciidoctor.extension.spi;version=\"${version}\""
instruction 'Import-Package',
'com.beust.jcommander;resolution:=optional',
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this line is necessary? Would the CLI ever be used from an OSGi environment. It's not really intended to be an API atm. But perhaps I'm missing a use case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely. It means that this import isn't required, so that the bundle will resolve even if the package com.beust.jcommander isn't available. All other packages are required though.

The gradle osgi plugin uses the bnd tool (https://github.com/bndtools/bnd) which processes these lines to produce the actual JAR and the final MANIFEST.MF.

You can also see that org.asciidoctor.cli is not part of the exported packages. It is still in the JAR but not exported, thus in an OSGi environment, other bundles can not use/see it.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the clarification! Now I get it.

'*'
}
}