-
-
Notifications
You must be signed in to change notification settings - Fork 302
Gradle Plugin
Bnd includes a plugin for Gradle users to build bnd projects. The biz.aQute.bnd.gradle
jar contains the bnd Gradle plugin. This plugin requires at least Gradle 2.0.
The bnd Gradle plugin builds a project based upon the information specified in the project's bnd.bnd
file and the workspace's cnf/build.bnd
file.
The bnd Gradle plugin has the Gradle plugin name biz.aQute.bnd
.
When creating the cnf project for a new workspace with bndtools, by default, the files for a gradle build will be installed the workspace. This includes the following files in the root of the workspace:
-
gradle.properties
- Some initial properties to configure the Gradle build for the workspace. -
settings.gradle
- Initializes the projects to be included in the Gradle build for the workspace. -
build.gradle
- Configures the projects in the Gradle build for the workspace.
These files can be modified to customize the overall Gradle build for the workspace. If special Gradle build behavior is needed, beyond changes to the project's bnd.bnd
file, then you should place a build.gradle
file in the root of the project and place your customizations in there.
Also, cnf/gradle/biz.aQute.bnd.gradle.jar
is installed which is referenced by the gradle.properties
file as the location of the bnd Gradle plugin.
If you are using the Gradle build added by bndtools when creating the cnf project in your workspace, you don't need to do anything else. If you want to use the bnd Gradle plugin in your existing Gradle build, you need to add the bnd Gradle plugin jar to your buildscript classpath and then apply the plugin to your project. For example:
buildscript {
dependencies {
classpath files('path/to/biz.aQute.bnd.gradle.jar')
}
}
apply plugin: 'biz.aQute.bnd'
We plan to make the bnd Gradle plugin available for use by the new Gradle plugins DSL soon.
The bnd Gradle plugin extends the standard Gradle Java plugin. It modifies some of the standard Java plugin tasks as necessary and also adds some additional tasks. Running gradle tasks --all
in a project will provide a complete list of the tasks available within the project.
The dependencies for the project are configured from the path information specified in the bnd.bnd
file such as -buildpath
and -testpath
. These paths are then used by various tasks such as compileJava
and compileTestJava
.
The jar
task uses bnd to build the project's bundles.
The test
task runs any plain JUnit tests in the project.
The check
task runs any OSGi JUnit tests in the project by launching a framework and running the tests in the launched framework.
The release
task releases the project's bundles to the -releaserepo
, if one is configured for the project.
The releaseNeeded
task releases the project and all projects it depends on.
The checkNeeded
task runs the check
task on the project and all projects it depends on.
The cleadNeeded
task cleans the project and all projects it depends on.
The export.
name tasks, one per bndrun file in the project, exports the name.bndrun
file to an executable jar.
The export
task will export all the bndrun files to executable jars.
The runbundles.
name tasks, one per bndrun file in the project, creates a distribution of the -runbundles of the name.bndrun
file.
The runbundles
task will create distributions of the runbundles for all the bndrun files.
The echo
task will display some help information on the dependencies, paths and configuration of the project.
The bndproperties
task will display the bnd properties of the project.
If you do need to write a build.gradle
file for a bnd project, there are some properties of the bnd Gradle plugin you will find useful.
- The
bndWorkspace
property of therootProject
contains the Workspace object. - The
bnd.project
property of the project contains the Project object.
Bnd properties for a project can be accessed in several ways. Given the example property name foo
, you can use the bnd
function, bnd('foo', 'defaultValue')
, or directly from the bnd extension, bnd.foo
. To access bnd properties without any macro processing you can use the bndUnprocessed
function, bndUnprocessed('foo', 'defaultValue')
.
For full details on what the bnd Gradle plugin does, check out the source code.