Builds Ubuntu ROCK image for your application using Gradle or Maven. The plugin requires rockcraft installed.
The build plugins generate rockcraft.yaml in the output directory and build a rock image for your application.
The plugins provide tasks/goals to build and deploy rock image.
The parts generated are prefixed with a build system name, e.g. gradle or maven.
The plugins create the following parts in rockcraft.yaml:
<build-system>/rockcraft/runtime: e.g.maven/rockcraft/runtimeorgradle/rockcraft/runtime. This part generates a Java runtime image for the application usingjlink. The part finds all jar files in the target image/jarsdirectory and generates a runtime image deployed in the/usr/jvm/java-<version>-openjdk-<arch>/directory. It creates a symlink tojavaexecutable in/usr/bin/java.<build-system>/rockcraft/deps: deploys openjdk runtime dependencies.<build-system>/rockcraft/dump: copies build artifact into target image's/jarsdirectory.
The rock is built using the base bare image.
The generated rockraft.yaml can be overridden by providing rockcraftYaml configuration property to the plugin. The plugin merges the generated rockcraft.yaml and the override one.
| Name | Description |
|---|---|
| buildPackage | OpenJDK Ubuntu package used to create a runtime image, e.g. openjdk-21-jdk-headless |
| targetRelease | --multi-release option passed to jlink |
| summary | rock image summary, e.g. Spring Boot Application |
| description | path to the description file, e.g. README.md |
| command | command used for the startup service |
| source | Git URL of chisel-releases repository |
| branch | Git branch of chisel-releases repository |
| architectures | list of the supported architectures, e.g. amd64, arm64 |
| slices | list of additional chisel slices to install |
| rockcraftYaml | path to rockcraft.yaml with the overrides for the generated rockraft.yaml |
| createService | create startup service (default true) |
| distTask | task/goal that creates application distribution that can be deployed to the container (default empty) |
Install rockcraft: snap install rockcraft.
To use the plugin, apply the following two steps:
Groovy
plugins {
id 'io.github.rockcrafters.rockcraft' version '1.2.2'
}
Kotlin
plugins {
id("io.github.rockcrafters.rockcraft") version "1.2.2"
}
Groovy
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'io.github.rockcrafters.rockcraft:1.2.2'
}
}
apply plugin: 'io.github.rockcrafters.rockcraft-plugin'
Kotlin
buildscript {
repositories {
maven {
setUrl("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("io.github.rockcrafters.rockcraft:1.2.2")
}
}
apply(plugin = "io.github.rockcrafters.rockcraft")
The plugin allows setting up container summary and description, target architectures and the startup service command line.
Groovy
rockcraft {
buildPackage = 'openjdk-21-jdk'
targetRelease = 21
summary = 'A ROCK summary'
description = 'README.md'
command = '/usr/bin/java -jar jars/application.jar'
source = 'http://github.com/myuser/chisel-releases'
branch = 'my-chisel-release-branch'
slices = ['busybox_bins', 'fontconfig_config']
architectures = ['amd64', 'arm64']
createService = false
rockcraftYaml = 'rockcraft.yaml'
}
Kotlin
rockcraft {
buildPackage = "openjdk-21-jdk"
targetRelease = 21
summary = "A ROCK summary"
description = "README.md"
command = "/usr/bin/java -jar jars/application.jar"
source = "http://github.com/myuser/chisel-releases"
branch = "my-chisel-release-branch"
slices("busybox_bins", "fontconfig_config")
architectures("amd64", "arm64")
createService = false
setRockcraftYaml("rockcraft.yaml")
}
The plugin provides dependencies-export task that stores project dependencies into build/build-rock/dependences.
This is equivalent to Maven dependency plugin
go-offline goal.
By default, the task exports all resolvable configurations of the project and buildscript.
The dependenciesExport configuration allows to customize the list of exported configurations.
Groovy
dependenciesExport {
buildScript = true
configurations = ["runtimeClasspath", "testRuntimeClasspath"]
}
Kotlin
dependenciesExport {
buildScript = true
configurations("runtimeClasspath", "testRuntimeClasspath")
}
The plugin provides create-build-rock and build-build-rock tasks
that creates a chiselled build container. It contains a local maven
repository with all the project dependencies, chiselled openjdk
and Gradle installation.
Groovy
buildRockcraft {
buildPackage = "openjdk-21-jdk"
summary = "A ROCK summary"
description = "README.md"
source = "http://github.com/myuser/chisel-releases"
branch = "my-chisel-release-branch"
slices("busybox_bins", "fontconfig_config")
architectures("amd64", "arm64")
rockcraftYaml = "rockcraft.yaml"
}
Kotlin
buildRockcraft {
buildPackage = "openjdk-21-jdk"
summary = "A ROCK summary"
description = "README.md"
source = "http://github.com/myuser/chisel-releases"
branch = "my-chisel-release-branch"
slices("busybox_bins", "fontconfig_config")
architectures("amd64", "arm64")
setRockcraftYaml("rockcraft.yaml")
}
Please see examples to try the sample projects.
Install rockcraft: snap install rockcraft.
The plugin goals have rockcraft prefix. For example, mvn rockcraft:push-rock will attempt to build runtime image and push it to the local docker daemon.
To use the plugin, apply the following two steps:
Apply the plugin:
<build>
<plugins>
...
<plugin>
<groupId>io.github.rockcrafters</groupId>
<artifactId>rockcraft-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<!-- creates rockcraft.yaml -->
<goal>create-rock</goal>
<!-- builds rock image -->
<goal>build-rock</goal>
<!-- pushes rock to the local docker daemon-->
<goal>push-rock</goal>
<!-- creates build container rockcraft.yaml -->
<goal>create-build-rock</goal>
<!-- builds build rock image -->
<goal>build-build-rock</goal>
<!-- pushes build rock to the local docker daemon-->
<goal>push-build-rock</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>The plugin supports all configuration options.
<plugins>
<plugin>
<groupId>io.github.rockcrafters</groupId>
<artifactId>rockcraft-maven-plugin</artifactId>
...
<configuration>
<buildPackage>openjdk-17-jdk-headless</buildPackage>
<targetRelease>17</targetRelease>
<jlink>false</jlink>
<summary>foo</summary>
<description>readme.txt</description>
<source>https://github.com/canonical/chisel-releases</source>
<branch>ubuntu-24.04</branch>
<architectures>
<architecture>amd64</architecture>
<architecture>arm64</architecture>
</architectures>
<slices>
<slice>busybox_bins</slice>
<slice>dash_bins</slice>
</slices>
</configuration>
</plugin>
</plugins>Build
<plugins>
<plugin>
<groupId>io.github.rockcrafters</groupId>
<artifactId>rockcraft-maven-plugin</artifactId>
...
<configuration>
...
<!-- allows use of artifacts in the local Maven repository in the build container, default false -->
<allowLocal>true</allowLocal>
</configuration>
</plugin>
</plugins>Please see examples to try the sample projects.
Issues can be reported to the Issue tracker.
Contributions can be submitted via Pull requests,
- Error handling (empty jar file), no main class