Gradle plugin¶
The Gradle plugin builds Java projects using the Gradle build tool.
After a successful build, this plugin will:
Create
bin/andjar/directories in$CRAFT_PART_INSTALL.Find the
javaexecutable provided by the part and link it as$CRAFT_PART_INSTALL/bin/java.Hard link the
.jarfiles generated in$CRAFT_PART_BUILDto$CRAFT_PART_INSTALL/jar.
Keys¶
This plugin provides the following unique keys.
gradle-init-script¶
Type
str
Description
The path to the initialization script to run before the build script is run.
The command run is gradle --init-script <gradle-init-script>.
gradle-parameters¶
Type
list[str]
Description
The extra arguments to pass to Gradle.
gradle-task¶
Type
str
Description
The Gradle task to run during build.
Defaults to build.
gradle-use-daemon¶
Type
bool
Description
Whether to use the Gradle daemon during build.
Defaults to false.
Attributes¶
This plugin supports the self-contained build attribute. Declaring this attribute
redirects all dependency resolution to a local Maven repository by overriding repository
settings. All dependencies, including plugins, must then be provided as build packages or
in an earlier part.
Environment variables¶
Environment variables can be specified to modify the behavior of the build. For the
Gradle plugin, three proxy environment variables are treated specially: http_proxy,
https_proxy and no_proxy. For a list of environment variables used to configure
Gradle, please refer to Configuring the build environment.
http_proxy¶
URL to proxy HTTP requests to. The value is mapped to the settings file
(.parts/.m2/settings.xml) under the proxy element.
https_proxy¶
URL to proxy HTTPS requests to. The value is mapped to the settings file
(.parts/.m2/settings.xml) under the proxy element.
no_proxy¶
A comma-separated list of hosts that should be not accessed via proxy.
Example¶
Here is a consolidated example of how to use the Gradle plugin.
plugin: gradle
source: .
gradle-init-script: <path-to-gradle-init-script>
gradle-parameters:
- -D<some-parameter>=<some-value>
gradle-task: build
build-snaps:
- gradle
For possible values of each field, refer to the Gradle documentation.
gradle-parameters: Command line interfacegradle-task: Understanding tasksbuild-environment: Configuring the build environment