public class BndManifestPlugin extends ProjectPlugin
Generates a manifest using purely bnd, and outputs it for IDE consumption.
Generating manifests by hand is a recipe for mistakes. Bnd does a fantastic job generating all this stuff for you, but there’s a lot of wiring required to tie bnd into both Eclipse PDE and Gradle. Which is what Goomph is for!
apply plugin: 'com.diffplug.gradle.eclipse.bndmanifest'
// Pass headers and bnd directives: http://www.aqute.biz/Bnd/Format
jar.manifest.attributes(
'-exportcontents': 'com.diffplug.*',
'-removeheaders': 'Bnd-LastModified,Bundle-Name,Created-By,Tool,Private-Package',
'Import-Package': '!javax.annotation.*,*',
'Bundle-SymbolicName': "${project.name};singleton:=true",
)
// The block below is optional.
osgiBndManifest {
// The manifest will always be included in the built jar
// at the proper 'META-INF/MANIFEST.MF' location. But if
// you'd like to easily see the manifest for debugging or
// to help an IDE, you can ask gradle to copy the manifest
// into your source tree.
copyTo 'src/main/resources/META-INF/MANIFEST.MF'
// By default, the existing manifest is completely ignored.
// The line below will cause the existing manifest's fields
// to be merged with the fields set by bnd.
mergeWithExisting true
}
Besides passing raw headers and bnd directives, this plugin also takes the following actions:
Bundle-Version
hasn’t been set explicitly.-SNAPSHOT
in the version with .IyyyyMMddkkmm
(to-the-minute timestamp).runtime
configuration’s classpath to bnd for manifest calculation.processResources
task.Many thanks to JRuyi and Agemo Cui for their excellent osgibnd-gradle-plugin. This plugin follows the template set by their plugin, but with fewer automagic features and tighter integrations with IDEs and gradle’s resources pipeline.
Constructor and Description |
---|
BndManifestPlugin() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyOnce(Project proj)
Plugin application, which is guaranteed to execute only once.
|
apply, getPlugin, treeDef
protected void applyOnce(Project proj)
ProjectPlugin
Plugin application, which is guaranteed to execute only once.
applyOnce
in class ProjectPlugin