Maven plugin¶
Maven plugin is a plugin that simplifies building and packaging Jars for projects that use the Maven (mvn) tooling. It is equivalent to running the following command:
mvn package
The maven-parameters key passes arguments to the mvn package command. The
parameter can also configure any command-line arguments. All values are passed after the
initial package command, delimited by spaces.
The maven-use-wrapper key leverages Maven wrapper files provided by the project to run
the package command. It replaces the default Maven executable with the project’s
mvnw file, to where the package command becomes ./mvnw package.
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.
Keywords¶
In addition to the common plugin and sources keywords, this plugin provides the following plugin-specific keywords:
maven-parameters¶
Type: list of strings
Used to add additional parameters to the mvn package command line.
maven-use-wrapper¶
Type: boolean
Used to determine whether the build should use the Maven wrapper provided by the project
at <project-root>/mvnw. If turned on, the project command is replaced with ./mvnw
package.
Environment variables¶
Environment variables can be specified to modify the behavior of the build. Three proxy-related, case-insensitive environment variables are treated specially:
http_proxyhttps_proxyno_proxy
For a list of environment variables used to configure Maven, please refer to Configuring Apache Maven.
http_proxy¶
URL to proxy HTTP request to. The value is mapped to the settings file
(.parts/.m2/settings.xml) under the proxy element.
https_proxy¶
URL to proxy HTTPS request 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.
Dependencies¶
The plugin expects Maven to be available on the system as the mvn executable, unless
a part named maven-deps is defined. In this case, the plugin will assume that this
part will stage the mvn executable to be used in the build step.
Note that the Maven plugin does not make a Java runtime available in the target environment. This must be handled by the developer when defining the part, according to each application’s runtime requirements.