Gradle 1.12 User Guide translation-Chapter 4. OSGi plug-in, gradleosgi
This article is translated by a CSDN blog blogger. For other chapters, see:
Http://blog.csdn.net/column/details/gradle-translation.html
Please pay attention to the address on Github for translation projects:
Https://github.com/msdx/gradledoc/tree/1.12.
To view the bilingual documents directly, visit:
Http://gradledoc.qiniudn.com/1.12/userguide/userguide.html.
In addition, Android mobile users can browse documents through a program I wrote with the cache function. The current version 0.2.1 is compatible with android 2.2 and later. The address is as follows:
Http://www.wandoujia.com/apps/com.githang.gradledoc
It is not easy to translate. For more information, see the source of this article on the CSDN blog:
Http://blog.csdn.net/maosidiaoxian/article/details/46825947
For my translations of Gradle, refer to the project on Github and documents on the http://gradledoc.qiniudn.com. If any translation error is found, it will be updated in the above two places first. Due to time and energy problems, the translations published in the blog are basically not modified simultaneously.
Chapter 4. OSGi plug-ins
The OSGi plug-in provides a factory method to createOsgiManifest
Object.OsgiManifest
Inherited fromManifest
. For more information about common list processing, see section 23.13.1 "Manifest ". If the Java Plug-in is applied, the OSGi plug-in replaces the default jar manifest object withOsgiManifest
Object. The replaced manifest is merged into the new object ticket.
The OSGi plug-in enables Peter Kriens BND tool to be widely used.
37.1. Usage
To use the OSGi plug-in, include the following statement in the build script:
Example 37.1. Use the OSGi plug-in
build.gradle
apply plugin: 'osgi'
37.2. implicit application plug-in
Applicable to basic Java Plug-ins.
37.3. Task
This plug-in does not add any tasks.
37.4. Dependency Management
To be determined
37.5. Agreed object
The OSGi plug-in adds the following agreed objects:OsgiPluginConvention
37.5.1. Agreed attributes
The OSGi plug-in does not add any Convention attributes to the project.
37.5.2. agreed methods
The OSGi plug-in adds the following methods. For more information, see the API documentation for the agreed object.
Table 37.1. OSGi Method
Method |
Return type |
Description |
OsgiManifest () |
OsgiManifest |
Returns an OsgiManifest object. |
OsgiManifest (Closure cl) |
OsgiManifest |
Returns an OsgiManifest object configured through a closure. |
The class files under the classes directory are analyzed to determine the dependencies of their packages and the package names they publish. And calculate OSGi Manifest based on thisImport-PackageAndExport-Package. If the classpath contains the jar package and OSGi bundle, the bundle information is used to specifyImport-PackageThe version information of the value. InOsgiManifest
You can add instructions next to an explicit property of an object.
Example 37.2. 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 parameter called by instruction is the attribute key. Other parameters constitute their values. They are used by Gradle,
Delimiter connection. To learn more