No description, website, or topics provided.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper gradle 3.2.1 Jan 1, 2017
src Update version up to 0.10.1-SNAPSHOT Jan 2, 2017
.gitignore allow for eclipse Jul 9, 2014
.travis.yml Fix the version of groovy used by travis Jan 5, 2015
LICENSE Create LICENSE May 20, 2014
README.md Update README with contact information Sep 25, 2018
build.gradle Update version up to 0.10.1-SNAPSHOT Jan 2, 2017
gradlew Gradle 2.13 Apr 25, 2016
gradlew.bat Gradle 2.13 Apr 25, 2016

README.md

Gradle Bundle Plugin

Build Status Gradle Status Download License

Gradle Bundle Plugin allows you to create OSGI bundles. Its main difference from the Gradle OSGI Plugin is that it uses the bnd tool to generate not only a manifest but a whole jar.

Project Status

The project is no longer maintained (due to lack of time). You are free to fork it or use any of the existing forks under Apache 2.0 license. If anyone is interested in resurrecting the project and become its maintainer you can email me at dm.artyom@gmail.com.

Installation

Plugin is hosted in Maven Central Repository. You can easily add plugin to your build script using following configuration

plugins {
    id 'org.dm.bundle' version '0.10.0'
}

Depending on the type of your project you also need to add id 'java' or id 'groovy', etc.

Tasks

jar

Generates an OSGI bundle.

When you apply the bundle plugin, Jar task no longer uses gradle Java plugin to generate the output but rather delegates this action to the bnd tool. The latter, however, uses the 'Jar' task customization, such as extension, baseName, etc.

Customization

Instructions

To customise the plugin's behaviour you can either add bnd instructions as attributes of the jar manifest or you can specify them in bundle extension (the latter will take precedence over the former). An example:

jar {
    manifest {
        attributes 'Implementation-Title': 'Bundle Quickstart', 	// Will be added to manifest
                         'Import-Package': '*'	// Will be overwritten by the insturctions below
    }
}

bundle {
    instructions << [
        'Bundle-Activator': 'foo.bar.MyBundleActivator',
        'Import-Package': 'foo.*',
        '-sources': true
    ]
    
    instruction 'Export-Package', '*' // Specify an individual instruction
    instruction '-wab', ''
}

Note that restrictions of the bnd tool hold true, that is for example instruction '-sources': true will not include groovy or scala sources.

Bnd tracing

You can enable bnd tracing by setting bundle.trace to true.

bundle {
    trace = true
}

Failing build in case of bnd build errors

You can make Gradle to fail the build in case of bnd build errors by setting bundle.failOnError to true.

bundle {
    failOnError = true
}

Passing transitive dependencies to Bnd

By default transitive dependencies are not included to the classpath passed to Bnd, to include them includeTransitiveDependencies needs to be set to true.

bundle {
    includeTransitiveDependencies = true
}

Exclusion of dependencies from the classpath passed to Bnd

This can be done using exclude property of bundle extension, for example:

bundle {
    exclude module: 'guava'
    exclude group: 'org.jmock'
}

Exclusion of project properties from the set of instructions passed to Bnd

By default the project properties are passed to Bnd (which means they may end up in the resulting MANIFEST.MF), this can be prevented by setting passProjectProperties to false:

bundle {
    passProjectProperties = false
}

Blueprint support

To enable blueprint support you need to pass the following instruction to Bnd:

bundle {
    instruction '-plugin', 'aQute.lib.spring.SpringXMLType'
}

Known issues

When the Gradle Daemon is enabled for a multi-module project, the plugin may produce a compilation bad class file error. To get around it compilation needs to be run in a separate process, i. e. the following settings need applying:

subprojects {
	...

	compileJava {
		options.fork = true
	}
	
	...
}

Gradle 1.x support

The current version of plugin assumes Gradle 2.x is used. The last version that supports Gradle 1.x is 0.5, which can be added to your script as follows

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'org.dm.gradle:gradle-bundle-plugin:0.5'
    }
}

apply plugin: 'bundle'