May 25, 2021 Gradle
The OSGi plug-in provides a factory way to create an Osgi Manifest object. O sgi Manifest inherited from Manifest. I f the Java plug-in is applied, the OSGi plug-in replaces the manifest object of the default jar with an OsgiManifest object. The replaced manifest is merged into the new object sheet.
The OSGi plug-in makes Peter Kriens BND tool widely available.
To use the OSGi plug-in, include the following statement in the build script:
Use the OSGi plug-in
build.gradle
apply plugin: 'osgi'
For Java underlying plug-ins.
This plug-in does not add any tasks.
To be decided
The OSGi plug-in adds the following convention object: OsgiPluginConvention
The OSGi plug-in does not add any convention properties to the project.
The OSGi plug-in adds the following methods. For more details, see the API documentation for contract objects.
Table 37.1. OSGi method
Method | Returns the type | Describe |
osgiManifest() | OsgiManifest | Returns an Osgi Manifest object. |
osgiManifest(Closure cl) | OsgiManifest | Returns an Osgi Manifest object configured through a closure. |
Class files in the classes directory are analyzed to analyze the dependencies on their packages and the name of the packages they publish. B ased on this calculation, the values of Import-Package and Export-Package in OSGi Manifest are calculated. I f classpath contains jar packages and OSGi bundles, bundle information is used to specify version information for the value of Import-Package. Next to the explicit properties of the Osgi Manifest object, you can add instructions.
OSGi MANIFEST. MF file configuration
build.gradle
jar {
manifest { // the manifest of the default jar is of type OsgiManifest
name = 'overwrittenSpecialOsgiName'
instruction 'Private-Package',
'org.mycomp.package1',
'org.mycomp.package2'
instruction 'Bundle-Vendor', 'MyCompany'
instruction 'Bundle-Description', 'Platform2: Metrics 2 Measures Framework'
instruction 'Bundle-DocURL', 'http://www.mycompany.com'
}
}
task fooJar(type: Jar) {
manifest = osgiManifest {
~instruction 'Bundle-Vendor', 'MyCompany'
}
}
The first argument called by instruction is the key of the property. O ther parameters make up its value. They are used by Gradle and connected by separators.