1 # <a name="Introduction"/>Introduction
3 This workspace is setup to be built with [Gradle](http://www.gradle.org).
5 The build is setup in such a way that Bnd (OSGi) projects and projects with
6 specific gradle files are automatically included in the build; no editing of
7 Gradle build scripts is needed.
9 A simple command in the root of the workspace is enough to build it all:
15 **Note**: The official Bnd Gradle plugin is used so that the same build
18 However, compared to the official Bnd Gradle plugin, this workspace build
19 setup adds some extra features to the build...
21 First off, the build setup is far more flexible and featureful than the build
22 setup that is delivered by Bndtools itself.
24 Among other things it has the following extra features:
26 * Support for FindBugs
27 * Support for JUnit code coverage reports through Jacoco
28 * An easily customisable setup
30 * Automatic location of the configuration (```cnf```) project
33 In order to use this workspace setup in a new workspace, add the
34 URL ```https://gitlab.com/fhuberts/bndtoolsWorkspace.git``` (use
35 the ```origin/master``` branch) to the ```Raw Git Clone URLs``` pane
36 in the Eclipse ```Prefrences->Bndtools->Generated Resources``` window.
38 Next time you create an OSGi workspace you can choose to use this
39 workspace setup. If you want to update your workspace with a new version
40 of this workspace setup, then simply do the same as when creating a new
41 workspace, in the existing workspace you want to update.
43 This workspace is compatible with Bndtools 2.3.0.REL and later.
46 # <a name="License"/>License
48 This document is licensed under the GNU Free Documentation License,
49 Version 1.3, 3 November 2008
52 # <a name="OpenSource"/>Open Source
54 The plugin was originally developed for - and delivered with - Bndtools 2.3.0
55 but has since been replaced with a different implemention in Bndtools.
57 The plugin was thereon forked and now lives on through the support
58 of [Pelagic](http://www.pelagic.nl).
60 The project is fully Open Source, licensed under the LGPL, and can be found
61 at [GitLab](https://gitlab.com/fhuberts/bndtoolsWorkspace).
63 Contributions are welcome!
66 # <a name="TableOfContents"/>Table Of Contents
68 * [Introduction](#Introduction)
70 * [Open Source](#OpenSource)
71 * [Table Of Contents](#TableOfContents)
72 * [Installing Gradle](#InstallingGradle)
73 * [On The System](#InstallingGradleOnTheSystem)
74 * [In The Workspace](#InstallingGradleInTheWorkspace)
75 * [Configuring The Gradle Daemon](#ConfiguringTheGradleDaemon)
76 * [Projects & Workspaces](#ProjectsAndWorkspaces)
77 * [Root Project](#ProjectsAndWorkspacesRootProject)
78 * [Sub-Projects](#ProjectsAndWorkspacesSubProjects)
79 * [Gradle Workspace](#ProjectsAndWorkspacesGradleWorkspace)
80 * [Bnd Workspace](#ProjectsAndWorkspacesBndWorkspace)
81 * [Configuration Project](#ProjectsAndWorkspacesCnf)
82 * [Bnd Project Layout](#ProjectsAndWorkspacesBndProjectLayout)
83 * [Build Flow](#BuildFlow)
84 * [Build Tasks](#BuildTasks)
85 * [Bnd Projects](#BuildTasksBndProjects)
86 * [jar](#BuildTasksJar)
87 * [testOSGi](#BuildTasksTestOSGi)
88 * [check](#BuildTasksCheck)
89 * [checkNeeded](#BuildTasksCheckNeeded)
90 * [release](#BuildTasksRelease)
91 * [releaseNeeded](#BuildTasksReleaseNeeded)
92 * [runbundles.<name>](#BuildTasksRunBundlesName)
93 * [runbundles](#BuildTasksRunbundles)
94 * [export.<name>](#BuildTasksExportName)
95 * [export](#BuildTasksExport)
96 * [resolve.<name>](#BuildTasksResolveName)
97 * [resolve](#BuildTasksResolve)
98 * [run.<name>](#BuildTasksRunName)
99 * [testrun.<name>](#BuildTasksTestRunName)
100 * [echo](#BuildTasksEcho)
101 * [bndproperties](#BuildTasksBndProperties)
102 * [clean](#BuildTasksClean)
103 * [cleanNeeded](#BuildTasksCleanNeeded)
104 * [All Projects](#BuildTasksAllProjects)
105 * [clean](#BuildTasksAllClean)
106 * [cleanNeeded](#BuildTasksAllCleanNeeded)
107 * [distClean](#BuildTasksDistClean)
108 * [distcleanNeeded](#BuildTasksDistCleanNeeded)
109 * [Java Projects](#BuildTasksJavaProjects)
110 * [Findbugs](#BuildTasksFindbugs)
111 * [findbugsMain](#BuildTasksFindbugsMain)
112 * [findbugsTest](#BuildTasksFindbugsTest)
113 * [findbugs](#BuildTasksfindbugs)
114 * [findbugstest](#BuildTasksfindbugstest)
115 * [Settings](#FindbugsSettings)
116 * [Jacoco](#BuildTasksJacoco)
117 * [Settings](#BuildTasksJacocoSettings)
118 * [javadoc](#BuildTasksJavadoc)
119 * [Settings](#BuildTasksJavadocSettings)
120 * [clean](#BuildTasksJavaClean)
121 * [Root Project](#BuildTasksRootProject)
122 * [wrapper](#BuildTasksWrapper)
123 * [Settings](#BuildTasksRootProjectSettings)
124 * [Build Options](#BuildOptions)
125 * [Bnd Projects](#BuildOptionsBndProjects)
126 * [Findbugs](#BuildOptionsFindbugs)
127 * [Customising The Build](#CustomisingTheBuild)
128 * [Gradle](#CustomisingTheBuildGradle)
129 * [Bnd](#CustomisingTheBuildBnd)
130 * [Adding Java Projects To The Build](#AddingJavaProjectsToTheBuild)
131 * [OSGi Repository Indexing](#BuildIndexing)
132 * [Jenkins Build Setup](#JenkinsBuildSetup)
135 # <a name="InstallingGradle"/>Installing Gradle
138 ## <a name="InstallingGradleOnTheSystem"/>On The System
140 Obviously, Gradle must be installed on the system before the workspace can be
143 This description assumes a Linux machine. Details may vary on other OSes.
145 * Download Gradle from [http://www.gradle.org](http://www.gradle.org).
147 * Unpack the downloaded archive and put it in ```/usr/local/lib```
148 as ```/usr/local/lib/gradle-4.0``` (in case Gradle 4.0 was downloaded).
150 * Create a symbolic link to the Gradle installation directory to be able to
151 easily switch Gradle versions later on:
155 ln -s gradle-4.0 /usr/local/lib/gradle
158 * Put the Gradle executable ```/usr/local/lib/gradle/bin/gradle``` on
159 the search path by linking to it from ```/usr/local/bin```:
162 ln -s /usr/local/lib/gradle/bin/gradle /usr/local/bin/
166 ## <a name="InstallingGradleInTheWorkspace"/>In The Workspace
168 Gradle can be installed in the workspace so that the workspace can be built
169 on systems that do not have Gradle installed (like build servers).
173 * Open a shell and go into the workspace root directory.
175 * Assuming Gradle is properly installed on the system
176 (see [Installing Gradle On The System](#InstallingGradleOnTheSystem)), run:
182 If you want to install a specific version of Gradle, then use the
183 following syntax (the example installs Gradle 4.0):
186 gradle wrapper --gradle-version 4.0
189 * Commit the files that were created in the workspace to your version control
193 # <a name="ConfiguringTheGradleDaemon"/>Configuring The Gradle Daemon
195 Startup times of a Gradle build can be much improved by using the Gradle
198 The Gradle daemon works well when the Gradle build script dependencies are
199 not changed, which makes it well suited to regular development (where these
200 are not changed) but **not** for build servers.
202 The daemon can be easily setup by adding the following line
203 to ```~/.gradle/gradle.properties```:
206 org.gradle.daemon=true
209 Stopping the Gradle daemon is easily achieved by running:
216 # <a name="ProjectsAndWorkspaces"/>Projects & Workspaces
219 ## <a name="ProjectsAndWorkspacesRootProject"/>Root Project
221 The Gradle root project is the directory that contains
222 the ```settings.gradle``` file.
224 Gradle locates the root project by first looking for
225 the ```settings.gradle``` file in the directory from which it was run,
226 and - when not found - then by searching up in the directory tree.
229 ## <a name="ProjectsAndWorkspacesSubProjects"/>Sub-Projects
231 The build will include all projects in the build that are:
233 * **Bnd** projects: Directories directly below the root project with
234 a ```bnd.bnd``` file.
236 * **Gradle** projects: Directories directly below the root project with
237 a ```build.gradle``` file, **or**
238 a ```build-settings.gradle``` file.
241 ## <a name="ProjectsAndWorkspacesGradleWorkspace"/>Gradle Workspace
243 The Gradle workspace is rooted in the root project and consists of all
244 included projects - **Bnd** *and* **Gradle** projects.
247 ## <a name="ProjectsAndWorkspacesBndWorkspace"/>Bnd Workspace
249 The Bnd workspace is rooted in the root project and contains exactly one
250 configuration project, and zero or more **Bnd** projects.
252 For it to be a *useful* Bnd workspace, it will have to contain at least one
256 ## <a name="ProjectsAndWorkspacesCnf"/>Configuration Project
258 The configuration project is the directory that contains the ```build.bnd```
259 file, and is - by default - the ```cnf``` directory.
263 * Placeholder source directory (```src```).
265 * Bnd workspace configuration.
267 * ```ext/*.bnd```
269 The ```ext``` directory contains Bnd settings files that are loaded
270 **before** the ```build.bnd``` file.
272 The directory typically contains:
274 * ```junit.bnd```
276 This file defines a Bnd variable for the libraries that are needed on
277 the classpath when running JUnit tests.
279 * ```pluginpaths.bnd```
281 This file instructs Bnd to load a number of plugin libraries when it
282 runs. Typically it will not do anything, but its usual purpose is to
283 instruct Bnd to load repository plugins, or custom plugins, by adding
284 them to the ```-pluginpath``` instruction in this file.
286 * ```repositories.bnd```
288 This file configures the plugins that Bnd loads. Typically it will
289 configure the repository plugins that are loaded. However, if any
290 built-in plugins or custom plugins are loaded then these also will
291 have to be configured here. This file also defines which repository
292 is the release repository.
294 * ```build.bnd```
296 This file contains workspace-wide settings for Bnd and will override
297 settings that are defined in any of the ```ext/*.bnd``` files.
301 * ```buildrepo```
303 This repository contains libraries that are intended
304 **only for build-time** usage. None are intended to be deployed as
305 bundles into a running OSGi framework, and indeed they may cause
306 unexpected errors if they are used in such a fashion.
308 * ```localrepo```
310 This repository contains no libraries by default. It is intended for
311 external libraries that are needed by one or more of the projects.
313 * ```releaserepo```
315 This repository contains no libraries by default. By default, bundles
316 end up in this repository when they are released from within Eclipse.
318 * ```releaserepoCI```
320 This repository contains no libraries by default. By default, bundles
321 end up in this repository when they are released from a Gradle build
322 (When the Gradle ```-PCI``` option is used).
326 The ```cache``` directory contains libraries that are downloaded by the
327 build. If the build is self-contained then this cache only contains
328 libraries that are retrieved from the workspace itself during the build.
332 * ```cnf/gradle```
334 This directory contains all Gradle build script files that are used by
335 the Gradle build, dependencies for the build, and documentation
336 pertaining to the build.
338 * ```template```
340 This directory contains build script files that define the build.
341 These are **not** meant to be changed.
345 This directory contains build script files that are hooks into the
346 build process. They allow specification of overrides for various
347 settings, additions to the build, modifications to the build, etc.
349 These **are** meant to be changed when build customisations are needed.
351 * ```dependencies```
353 This directory contains libraries that are used by the build in the
354 form of a file repository.
358 This directory contains documentation pertaining to the build. The
359 document you're now reading is located in this directory.
361 <a name="svg"/>Also found in this directory is the
362 diagram [template.svg](template.svg) that provides an overview of the
363 build setup, much like the Gradle User Guide shows for the Java Plugin.
365 The diagram shows all tasks of the build and their dependencies:
367 * The light cyan blocks are tasks that are present by default, either
368 because Gradle creates them by default of because the project has
369 applied the Java plugin, which creates these tasks.
371 * The cyan block are tasks that are added or modified by the Bnd plugin.
373 * The orange blocks are tasks that are added or modified by this build
376 * The arrows depict **execution flow** (so the dependencies are in the
379 * The **red** arrows depict flows from dependent projects (dependencies
384 The ```compileJava``` task of a project is dependent on
385 the ```assemble``` task of another project if the latter project is
386 on the build path of the former project.
388 * The **yellow** arrows depict flows to parent projects (dependencies
389 from projects) . These are the reverse of the **red** arrows.
391 * The **blue** arrows depict flows/dependencies that are only present
392 when the task from which the flows originate is present in the
395 * The **green** arrows depict flows/dependencies that are disabled by
398 * The **magenta** arrows depict flows/dependencies that are
399 automatically scheduled to run when the tasks from which they
400 originate are scheduled to run.
403 [Bnd Gradle plugin README](https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/README.md)
404 for details about the Bnd supplied build tasks.
407 ## <a name="ProjectsAndWorkspacesBndProjectLayout"/>Bnd Project Layout
409 A Bnd project has a well defined layout with a number of source directories
410 and one output directory:
412 * Main sources: located in the ```src``` directory by default. Compiled
413 sources will be placed in the ```bin``` directory. Can be overridden with
414 the ```src``` and ```bin``` Bnd settings respectively.
416 * Test sources: located in the ```test``` directory by default. Compiled
417 sources will be placed in the ```bin_test``` directory. Can be overridden
418 with the ```testsrc``` and ```testbin``` Bnd settings respectively.
420 * Output directory ```generated```. Built OSGi bundles will be placed here.
421 Can be overridden with the ```target-dir``` Bnd setting
424 # <a name="BuildFlow"/>Build Flow
426 Understanding the build flow is especially important if the build must be
427 modified: extra tasks must be added, properties must be overridden, etc.
429 The build has the following flow:
431 * <a name="BuildProperties"/>Gradle loads all properties defined in
432 the ```gradle.properties``` file in the root of the workspace.
434 This file is used to bootstrap the build and (among other things) defines
435 the build dependencies:
437 * All ```*.uri``` settings are considered to be build dependencies.
439 An ```example.uri``` setting will make the build script add the file
440 indicated by the URI to the build dependencies when the file exists on
441 the local filesystem. If the file doesn't exist on the local filesystem,
442 then the build script will download the build dependency from the
443 specified URI into the ```cnf/cache``` directory and add it to the build
446 **Note**: Using a ```*.uri``` setting that points to an external location
447 is **not recommended** since the build will then no longer be
448 self-contained (because it needs network access).
450 * Gradle invokes the ```settings.gradle``` file in the root of the workspace.
451 This file initialises the build:
453 * Detect the location of the configuration project
454 (see [Configuration Project](#ProjectsAndWorkspacesCnf)).
456 * Initialise the Bnd workspace.
458 * The build dependencies are determined from the build properties that
459 were loaded from the ```gradle.properties``` file
460 (see [the explanation of the build properties file](#BuildProperties).
462 * Include all **Bnd** projects and all **Gradle** projects
463 (see [Sub-Projects](#ProjectsAndWorkspacesSubProjects) for an
466 * Gradle invokes the ```build.gradle``` file from the root project. This
467 file sets up the build:
469 * The Bnd plugin is loaded.
471 * The hook ```cnf/gradle/custom/workspace-pre.gradle``` is invoked.
473 * The rest of the build template basically has 3 sections which are applied
482 This section sets up the build for all included projects (including the
483 root project) by iterating over all included projects and performing the
484 actions described below.
486 * The Gradle build directory of the project is set to the Bnd
487 default (```generated```).
489 * The hook ```cnf/gradle/custom/allProject-pre.gradle``` is invoked.
491 * If the project has project specific build settings in
492 a ```build-settings.gradle``` file in its project root directory then
495 Project specific build settings allow - on a project-by-project basis -
496 overrides of the build settings, additions to the build, modifications
499 * Clean tasks are added to the project.
501 * The hook ```cnf/gradle/custom/allProject-post.gradle``` is invoked.
505 This section sets up the build for all included projects, (excluding the
506 root project) by iterating over all included sub-projects. In the
507 iteration a distinction is made between **Bnd** projects and **Gradle**
510 * The hook ```cnf/gradle/custom/subProject-pre.gradle``` is invoked.
512 * Gradle projects (Non-Bnd Projects)
514 * The hook ```cnf/gradle/custom/nonBndProject-pre.gradle``` is invoked.
516 * The default tasks are setup (specified by the ```others_defaultTask```
517 property). This is a comma separated list of task names.
521 * The Bnd project instance is stored in the project as
522 the ```bndProject``` property.
524 * The hook ```cnf/gradle/custom/bndProject-pre.gradle``` is invoked.
526 * The Bnd plugin is applied.
528 * The javadoc bootclasspath is adjusted to include the bootclasspath
531 * The hook ```cnf/gradle/custom/bndProject-post.gradle``` is invoked.
533 * All projects that have applied the Gradle Java plugin (which includes
536 * The hook ```cnf/gradle/custom/javaProject-pre.gradle``` is invoked.
538 * The javaDoc task is setup.
540 * The findbugs tasks are setup.
542 * The jacoco task is setup.
544 * The clean task is adjusted to clean all output directories of all
547 * The hook ```cnf/gradle/custom/javaProject-post.gradle``` is invoked.
549 * The hook ```cnf/gradle/custom/subProject-post.gradle``` is invoked.
553 This section sets up the build (defaults) for the root project.
555 * The hook ```cnf/gradle/custom/rootProject-pre.gradle``` is invoked.
557 * The default tasks are setup (specified by the ```root_defaultTask```
558 property). This is a comma separated list of task names.
560 * The wrapper task is setup.
562 * The distclean task is adjusted to also clean the ```cnf/cache```
563 and ```.gradle``` directories.
565 * The hook ```cnf/gradle/custom/rootProject-post.gradle``` is invoked.
567 * The hook ```cnf/gradle/custom/workspace-post.gradle``` is invoked.
569 * For every included project with a ```build.gradle``` build script, Gradle
570 invokes that build script.
572 * Gradle resolves the build setup.
574 * Gradle now builds the projects by running the specified (or default) tasks.
577 # <a name="BuildTasks"/>Build Tasks
579 The discussion of the build tasks below is split per project type.
582 ## <a name="BuildTasksBndProjects"/>Bnd Projects
584 This section only discusses tasks that are added or modified compared to the
588 ### <a name="BuildTasksJar"/>jar
590 This task instructs Bnd to construct the project's OSGi bundles. The bundles
591 are placed in the project's ```generated``` directory.
593 This is comparable to the ```jar``` task that is defined by the Java plugin,
594 which instructs the Java compiler to construct a standard jar. However, a
595 Bnd project completely replaces that ```jar``` task.
597 The ```bnd.bnd``` file describes how the OSGi bundle(s) must be constructed
598 and is therefore taken as input by Bnd.
600 This task is automatically disabled when no bundle(s) must be contructed.
603 ### <a name="BuildTasksTestOSGi"/>testOSGi
605 This task instructs Bnd to run bundle OSGi (integration) tests.
607 This is comparable to the ```test``` task that is defined by the Java plugin,
608 which instructs the Java runtime to run unit tests.
610 Refer to the Bnd manual/website for more details on how to setup bundle tests.
612 Set ```check.ignoreFailures = true``` on the project to not fail the build
615 This task is automatically disabled when no bundle tests have been defined.
618 ### <a name="BuildTasksCheck"/>check
620 This task instructs Bnd to run all tests.
622 Set ```check.ignoreFailures = true``` on the project to not fail the build
626 ### <a name="BuildTasksCheckNeeded"/>checkNeeded
628 This task will invoke the ```check``` task on all projects on which the
629 project is dependent, after which the ```check``` task is invoked on the
633 ### <a name="BuildTasksRelease"/>release
635 This task instructs Bnd to copy the constructed OSGi bundle into the release
638 This task is automatically disabled when no release repository is defined or
639 when no bundle(s) must be constructed.
642 ### <a name="BuildTasksReleaseNeeded"/>releaseNeeded
644 This task will invoke the ```release``` task on all projects on which the
645 project is dependent, after which the ```release``` task is invoked on the
649 ### <a name="BuildTasksRunBundlesName"/>runbundles.<name>
651 This task will copy all runbundles metioned in the ``<name>.bndrun``` file in
652 the project to a distribution directory. The bundles are place in the
653 directory ```generated/distributions/runbundles/<name>```.
655 This task is only setup if the project contains a ```<name>.bndrun``` file.
658 ### <a name="BuildTasksRunbundles"/>runbundles
660 This task will invoke the ```runbundles.<name>``` for all ```*.bndrun```
661 files in the project.
663 This task is automatically disabled when the project contains
664 no ```*.bndrun``` files.
667 ### <a name="BuildTasksExportName"/>export.<name>
669 This task will export the ```<name>.bndrun``` file in the project to an
670 executable jar. The executable jar is placed in the
671 project's ```generated/distributions``` directory as ```<name>.jar```.
673 This task is only setup if the project contains a ```<name>.bndrun``` file.
676 ### <a name="BuildTasksExport"/>export
678 This task will export all ```*.bndrun``` files in the project to executable
681 This task is automatically disabled when the project contains
682 no ```*.bndrun``` files.
685 ### <a name="BuildTasksResolveName"/>resolve.<name>
687 This task will resolve the ```<name>.bndrun``` file in the project
688 and update the ```-runbundles``` instruction in the file.
690 This task is only setup if the project contains a ```<name>.bndrun``` file.
693 ### <a name="BuildTasksResolve"/>resolve
695 This task will resolves all ```*.bndrun``` files in the project and update
696 their ```-runbundles``` instructions.
698 This task is automatically disabled when the project contains
699 no ```*.bndrun``` files.
702 ### <a name="BuildTasksRunName"/>run.<name>
704 This task will run the ```<name>.bndrun``` file in the project.
706 This task is only setup if the project contains a ```<name>.bndrun``` file.
709 ### <a name="BuildTasksTestRunName"/>testrun.<name>
711 This task will run the OSGi JUnit tests in the ```<name>.bndrun``` file in
714 This task is only setup if the project contains a ```<name>.bndrun``` file.
717 ### <a name="BuildTasksEcho"/>echo
719 This task displays some key Bnd properties of the project.
722 ### <a name="BuildTasksBndProperties"/>bndproperties
724 This task - analogous to the Gradle ```properties``` task - displays the Bnd
725 properties that are defined for the project.
727 These properties are defined in the ```bnd.bnd``` file in the root of the
728 project (and optionally other ```*.bnd``` files when using the ```-sub```
729 instruction for sub-bundles).
731 Properties that are defined in workspace-wide ```*.bnd``` files that are
732 loaded from the configuration project (```cnf```) are also displayed as they
733 obviously also apply to the project (unless overridden by the project, in
734 which case the overridden values are shown).
737 ### <a name="BuildTasksClean"/>clean
739 This task instructs Bnd to clean up the project, which removes
740 the output directory and the directories that hold the class files.
742 This is in addition to the ```clean``` task that is defined by the Java plugin.
745 ### <a name="BuildTasksCleanNeeded"/>cleanNeeded
747 This task will invoke the ```clean``` task on all projects on which the
748 project is dependent, after which the ```clean``` task is invoked on the
752 ## <a name="BuildTasksAllProjects"/>All Projects
754 This section discusses tasks that are added to all projects.
757 ### <a name="BuildTasksAllClean"/>clean
759 This (empty) task is only added to the project when it doesn't yet have
760 a ```clean``` task. The reason for this is to be able to easily declare clean
764 ### <a name="BuildTasksAllCleanNeeded"/>cleanNeeded
766 This (empty) task is only added to the project when it doesn't yet have
767 a ```cleanNeeded``` task. The reason for this is to be able to easily declare
768 clean task dependencies.
771 ### <a name="BuildTasksDistClean"/>distClean
773 This (empty by default) task is meant to perform additional cleanup compared
774 to the ```clean``` task.
776 The build adjusts this task for the root project such that it removes:
778 * The cache directory in the configuration project.
780 * The Gradle cache directory.
783 ### <a name="BuildTasksDistCleanNeeded"/>distcleanNeeded
785 This task will invoke the ```distClean``` task on all projects on which the
786 project is dependent, after which the ```distClean``` task is invoked on the
790 ## <a name="BuildTasksJavaProjects"/>Java Projects
792 This section discusses tasks that are added to all Java projects (which
793 includes Bnd projects).
796 ### <a name="BuildTasksFindbugs"/>Findbugs
798 The findbugs plugin is applied to all Java projects. This plugin adds the
799 tasks ```findbugsMain``` and ```findbugsTest```.
801 These two tasks are disabled by default since running findbugs is an
802 expensive operation and is not needed for most builds. Enabling these tasks
805 **Note**: The reports that are generated by the findbugs tasks will only have
806 line numbers when the tasks are run on a build that produces artefacts with
809 #### <a name="BuildTasksFindbugsMain"/>findbugsMain
811 This task will run findbugs on the main source code.
813 #### <a name="BuildTasksFindbugsTest"/>findbugsTest
815 This task will run findbugs on the test source code.
817 #### <a name="BuildTasksfindbugs"/>findbugs
819 Specifying this (virtual) task will **enable** the ```findbugsMain``` task.
821 **Note**: It is still required to specify a task that has a dependency on
822 the ```findbugsMain``` task to actually run it. The tasks ```check```
823 and ```build``` are examples of such a task.
825 #### <a name="BuildTasksfindbugstest"/>findbugstest
827 Specifying this (virtual) task will **enable** the ```findbugsTest``` task.
829 **Note**: it is still required to specify a task that has a dependency on
830 the ```findbugsTest``` task to actually run it. The tasks ```check```
831 and ```build``` are examples of such a task.
833 #### <a name="FindbugsSettings"/>Settings
835 * ```findbugsReportXML```: The name of the property that must be defined
836 in order to generate XML reports instead of
837 HTML reports (since the findbugs plugin can't
838 create them both at the same time). Defaults
841 * ```findbugsIgnoreFailures```: **true** to ignore findbugs warning (to
842 **not** fail the build). Defaults
845 * ```findbugsIncludesFile```: The file with include rules. Defaults
846 to ```${rootProject.rootDir}/${rootProject.bnd_cnf}/findbugs/findbugs.include.xml```.
848 * ```findbugsExcludesFile```: The file with exclude rules. Defaults
849 to ```{rootProject.rootDir}/${rootProject.bnd_cnf}/findbugs/findbugs.exclude.xml```.
851 The defaults for the settings can be overridden by defining the settings in
852 the project's ```build-settings.gradle``` file.
855 ### <a name="BuildTasksJacoco"/>Jacoco
857 The jacoco plugin is applied to all Java projects. This plugin adds the
858 task ```jacocoTestReport``` which details the test coverage.
860 The ```jacocoTestReport``` task is automatically run when either or both of
861 the ```test``` and ```check``` tasks are scheduled to run.
863 An ```test.exec``` report - for consumption by a build server - is always
866 #### <a name="BuildTasksJacocoSettings"/>Settings
868 * ```jacocoToolVersion```: The version of the jacoco plugin to use.
869 Defaults to **0.7.5.201505241946**.
871 * ```jacocoXmlReport```: **true** to generate XML reports. Defaults
874 * ```jacocoCsvReport```: **true** to generate CSV reports. Defaults
877 The defaults for the settings can be overridden by defining the settings in
878 the project's ```build-settings.gradle``` file.
881 ### <a name="BuildTasksJavadoc"/>javadoc
883 This task generates javadoc for the main source code.
885 #### <a name="BuildTasksJavadocSettings"/>Settings
887 * ```javadocDir```: The directory (relative to the project's build
888 directory) in which to place the javadoc.
889 Defaults to **javadoc**.
891 * ```javadocTitle```: The same as ```javadocDocTitle```.
892 Defaults to **${project.name}**.
894 * ```javadocFailOnError```: **false** to ignore errors (to **not** fail
896 Defaults to **true**.
898 * ```javadocMaxMemory```: The maximum amount of memory that the javadoc
899 task is allowed to consume.
900 Defaults to **256M**.
902 * ```javadocVerbose```: **true** for verbose mode: provide more
903 detailed messages while javadoc is running.
904 Without the verbose option, messages appear for
905 loading the source files, generating the
906 documentation (one message per source file),
907 and sorting. The verbose option causes the
908 printing of additional messages specifying the
909 number of milliseconds to parse each java
911 Defaults to **false**.
913 * ```javadocDocTitle```: The title to be placed near the top of the
914 overview summary file. The title will be placed
915 as a centered, level-one heading directly
916 beneath the upper navigation bar. The title may
917 contain html tags and white space, though if it
918 does, it must be enclosed in quotes. Any
919 internal quotation marks within title may have
921 Defaults to **${project.name}**.
923 * ```javadocWindowTitle```: The title to be placed in the
924 HTML ```<title>``` tag. This appears in the
925 window title and in any browser bookmarks
926 (favorite places) that someone creates for
927 this page. This title should not contain
928 any HTML tags, as the browser will not
929 properly interpret them. Any internal
930 quotation marks within title may have to
932 Defaults to **${project.name}**.
934 * ```javadocClassPathBoot```: The bootclasspath.
935 Defaults to an empty list of files.
936 Is automatically set for Bnd projects.
938 * ```javadocMemberLevel```: The minimum member level to include in the
939 generated documention. Can be (from lowest
940 level to highest level): **PRIVATE**
941 , **PROTECTED**, **PACKAGE**, **PUBLIC**.
942 Defaults to **PUBLIC**.
944 * ```javadocEncoding```: The encoding name of the source files.
945 Defaults to **UTF-8**.
947 * ```javadocAuthor```: **true** to include the @author text in the
948 generated documentation.
949 Defaults to **true**.
951 * ```javadocBreakIterator```: **true** to use the internationalized
953 java.text.BreakIterator to determine the
954 end of the first sentence for English
955 (all other locales already use
956 BreakIterator), rather than an English
957 language, locale-specific algorithm. By
958 first sentence, the first sentence in the
959 main description of a package, class or
960 member is meant. This sentence is copied
961 to the package, class or member summary,
962 and to the alphabetic index.
963 Defaults to **true**.
965 * ```javadocDocFilesSubDirs```: **true** to enable deep copying
966 of "doc-files" directories. In other
967 words, subdirectories and all contents
968 are recursively copied to the
969 destination. For example, the
970 directory ```doc-files/example/images```
971 and all its contents would now be copied.
972 Defaults to **true**.
974 * ```javadocNoComment```: **true** to suppress the entire comment body,
975 including the main description and all tags,
976 generating only declarations. This option
977 enables re-using source files originally
978 intended for a different purpose, to produce
979 skeleton HTML documentation at the early
980 stages of a new project.
981 Defaults to **false**.
983 * ```javadocNoDeprecated```: **true** to prevent the generation of any
984 deprecated API at all in the documentation.
985 This does what ```javadocNoDeprecatedList```
986 does, plus it does not generate any
987 deprecated API throughout the rest of the
988 documentation. This is useful when writing
989 code and you don't want to be distracted
990 by the deprecated code.
991 Defaults to **false**.
993 * ```javadocNoDeprecatedList```: **true** to prevent the generation of
994 the file containing the list of
995 deprecated APIs (deprecated-list.html)
996 and the link in the navigation bar to
997 that page. (However, javadoc continues
998 to generate the deprecated API
999 throughout the rest of the document.)
1000 This is useful if your source code
1001 contains no deprecated API, and you
1002 want to make the navigation bar cleaner.
1003 Defaults to **false**.
1005 * ```javadocNoHelp```: **true** to omit the HELP link in the navigation
1006 bars at the top and bottom of each page of output.
1007 Defaults to **false**.
1009 * ```javadocNoIndex```: **true** to omit the index from the generated
1010 documentation. The index is produced by default.
1011 Defaults to **false**.
1013 * ```javadocNoNavBar```: **true** to prevent the generation of the
1014 navigation bar, header and footer, otherwise
1015 found at the top and bottom of the generated
1016 pages. Has no effect on the "bottom" option.
1017 The option is useful when you are interested
1018 only in the content and have no need for
1019 navigation, such as converting the files to
1020 PostScript or PDF for print only.
1021 Defaults to **false**.
1023 * ```javadocNoSince```: **true** to omit from the generated documentation
1024 the "Since" sections associated with the @since
1026 Defaults to **false**.
1028 * ```javadocNoTimestamp```: **true** to suppress the timestamp, which
1029 is hidden in an HTML comment in the generated
1030 HTML near the top of each page. Useful when
1031 you want to run javadoc on two source bases
1032 and diff them, as it prevents timestamps
1033 from causing a diff (which would otherwise
1034 be a diff on every page). The timestamp
1035 includes the javadoc version number.
1036 Defaults to **false**.
1038 * ```javadocNoTree```: **true** to omit the class/interface hierarchy
1039 pages from the generated documentation. These
1040 are the pages you reach using the "Tree" button
1041 in the navigation bar.
1042 Defaults to **false**.
1044 * ```javadocSplitIndex```: **true** to split the index file into
1045 multiple files, alphabetically, one file per
1046 letter, plus a file for any index entries
1047 that start with non-alphabetical characters.
1048 Defaults to **true**.
1050 * ```javadocUse```: **true** to include one "Use" page for each
1051 documented class and package. The page describes
1052 what packages, classes, methods, constructors and
1053 fields use any API of the given class or package.
1054 Given class C, things that use class C would
1055 include subclasses of C, fields declared as C,
1056 methods that return C, and methods and constructors
1057 with parameters of type C. You can access the
1058 generated "Use" page by first going to the class or
1059 package, then clicking on the "Use" link in the
1061 Defaults to **true**.
1063 * ```javadocVersion```: **true** to include the @version text in the
1064 generated documentation.
1065 Defaults to **true**.
1067 The defaults for the settings can be overridden by defining the settings in
1068 the project's ```build-settings.gradle``` file.
1071 ### <a name="BuildTasksJavaClean"/>clean
1073 The build adjusts this task for Java projects (which includes Bnd projects)
1074 such that it removes:
1076 * The class files output directory of all defined sourcesets.
1078 * The resources output directory of all defined sourcesets.
1081 ## <a name="BuildTasksRootProject"/>Root Project
1083 This section discusses tasks that are modified for the root project.
1085 ### <a name="BuildTasksWrapper"/>wrapper
1087 This task downloads Gradle and installs it in the workspace,
1088 see [Installing Gradle In The Workspace](#InstallingGradleInTheWorkspace).
1091 #### <a name="BuildTasksRootProjectSettings"/>Settings
1093 * ```rootGradleVersion```: The version of the Gradle to use when
1094 generating the Gradle wrapper.
1095 Not setting it will result in the latest
1096 released version of Gradle being used.
1099 The defaults for the settings can be overridden by defining the settings in
1100 the project's ```build-settings.gradle``` file.
1103 # <a name="BuildOptions"/>Build Options
1106 ## <a name="BuildOptionsBndProjects"/>Bnd Projects
1108 * The ```jar``` task can be disabled by:
1110 * Presence of the ```-nobundles``` instruction in the ```bnd.bnd``` file.
1112 * The ```test``` task can be disabled by:
1114 * Presence of the ```-nojunit``` instruction in the ```bnd.bnd``` file.
1116 * Presence of the ```no.junit``` property in the ```bnd.bnd``` file.
1118 * The ```check``` task can be disabled by:
1120 * Presence of the ```-nojunitosgi``` instruction in the ```bnd.bnd``` file.
1122 * Absence of the ```Test-Cases``` Bnd property in the ```bnd.bnd``` file.
1124 * The ```release``` task can be disabled by:
1126 * Presence of the ```-nobundles``` instruction in the ```bnd.bnd``` file.
1128 * Absence of the ```-releaserepo``` instruction in any of the Bnd files.
1131 ## <a name="BuildOptionsFindbugs"/>Findbugs
1133 The findbugs tasks will - by default - generate HTML reports, but can be
1134 instructed to generate XML reports by setting the ```CI``` Gradle system
1135 property (```-PCI``` on the command line).
1137 ```CI``` = **C**ontinous **I**ntegration
1138 (since XML reports are typically used on build servers)
1141 # <a name="CustomisingTheBuild"/>Customising The Build
1144 ## <a name="CustomisingTheBuildGradle"/>Gradle
1146 The build be can easily customised by putting overrides and additions in any
1147 of the ```cnf/gradle/custom/*.gradle``` build script hook files,
1148 see [Build Flow](#BuildFlow).
1150 Also, any project can - on an individual basis - customise build settings or
1151 specify additions by placing a ```build-settings.gradle``` file in its
1154 The ```build-settings.gradle``` file is meant for settings and settings
1155 overrides, the ```build.gradle``` file is meant for tasks.
1158 ## <a name="CustomisingTheBuildBnd"/>Bnd
1160 The Bnd default settings are shown in the ```cnf/build.bnd``` file.
1161 Overrides to workspace-wide Bnd settings can be placed in that same file.
1163 If a setting must be overridden or defined for a specific project, then that
1164 setting must be defined in the ```bnd.bnd``` file of that specific project.
1167 # <a name="AddingJavaProjectsToTheBuild"/>Adding Java Projects To The Build
1169 The build automatically includes all Bnd projects.
1171 However, regular Java projects are not included automatically:
1172 a ```build.gradle``` file or a ```build-settings.gradle``` file in the root
1173 directory of the project is needed to make that happen.
1175 Such projects only need to apply the Gradle Java plugin, setup their
1176 sourceSets, and setup their build directory. The template will then
1177 automatically apply the
1178 buildscript ```cnf/gradle/template/javaProject.gradle``` which adds tasks
1179 that are relevant to Java projects,
1180 see [Java Projects](#BuildTasksJavaProjects).
1182 The ```build-settings.gradle``` file shown below can be used as the basis.
1183 This will setup the Java project with the default Bnd layout and add tasks
1184 that are relevant to a Java project (```javadoc```, ```findbugs...```, etc.).
1188 * A java project with Bnd layout
1191 assert(project != rootProject)
1193 apply plugin: 'java'
1195 /* We use the same directory for java and resources. */
1198 java.srcDirs = resources.srcDirs = files('src')
1199 output.classesDir = output.resourcesDir = 'bin'
1202 java.srcDirs = resources.srcDirs = files('test' )
1203 output.classesDir = output.resourcesDir = 'test_bin'
1207 buildDir = 'generated'
1210 The ```build-settings.gradle``` file shown below can be used as the basis for a
1211 project with the Maven layout.
1215 * A java project with Maven layout
1218 assert(project != rootProject)
1220 apply plugin: 'java'
1222 /* We do not use the same directory for java and resources. */
1225 java.srcDirs = files('src/main/java' )
1226 resources.srcDirs = files('src/main/resources')
1227 output.classesDir = 'target/classes'
1228 output.resourcesDir = 'target/classes'
1231 java.srcDirs = files('src/test/java' )
1232 resources.srcDirs = files('src/test/resources')
1233 output.classesDir = 'target/test-classes'
1234 output.resourcesDir = 'target/test-classes'
1242 # <a name="BuildIndexing"/>OSGi Repository Indexing
1244 Indexing a tree of bundles to generate an OSGi repository index is now
1245 handled through Bnd's Index task,
1246 see [Bnd's README](https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/README.md#create-a-task-of-the-index-type).
1248 As an example, say you'd want to create a (compressed) repository index of all
1249 the bundles in the directory ```cnf/somerepo```. You would then create or
1250 adjust the file ```cnf/build.gradle``` and add something like below:
1253 import aQute.bnd.gradle.Index
1255 task index(type: Index) {
1256 destinationDir = file('somerepo')
1258 indexName = "your-custom-index.xml"
1259 repositoryName = "You Custom Index Name"
1260 bundles = fileTree(destinationDir) {
1262 exclude '**/*-latest.jar'
1263 exclude '**/*-sources.jar'
1264 exclude '**/*-javadoc.jar'
1270 # <a name="JenkinsBuildSetup"/>Jenkins Build Setup
1272 The screenshot ([Jenkins-Build-Settings.jpg](Jenkins-Build-Settings.jpg)) shows
1273 part of an example job.
1275 The shown settings can be used as an example, but can slightly differ for your
1278 The following Jenkins plugins should be installed to take advantage of the
1279 various functionalities of the build (some of which are shown in the
1282 * build timeout plugin
1285 * Git Parameter Plug-In
1293 Ensure your Jenkins has the most recent versions of these plugins.
1295 This applies especially to the Jacoco plugin since the binary format of Jacoco
1296 was changed a few times in the second half of 2015.