- jdk8, jdk8-jammy
- jdk8-focal
- jdk11, jdk11-jammy
- jdk11-focal
- jdk11-alpine
- jdk17, jdk17-jammy, latest
- jdk17-focal
- jdk17-alpine, alpine
- jdk17-graal, graal
- jdk17-focal-graal
- jdk21, jdk21-jammy
- jdk21-alpine
- jdk21-graal
Gradle currently has incomplete support for Java 21. The 8.4 release notes say
Gradle now supports using Java 21 for compiling, testing, and starting other Java programs. This can be accomplished by configuring your build or task to use a Java 21 toolchain.
You cannot currently run Gradle on Java 21 because Kotlin lacks support for JDK 21. However, you can expect support for running Gradle with Java 21 in a future version.
This is also noted in the compatibility guide. This means that you can't use Gradle with Java 21 with Kotlin DSL buildscripts, only Groovy DSL scripts.
This means things like using the kotlin-dsl
plugin in a buildSrc script aren't currently supported. The only way to run such projects for Java 21 is to launch Gradle with another JVM (8, 11, or 17) and then use Java 21 in a toolchain (requiring an image with both JVMs installed). This image doesn't exist currently. If this is something you need, please upvote this PR.
Gradle is a build tool with a focus on build automation and support for multi-language development. If you are building, testing, publishing, and deploying software on any platform, Gradle offers a flexible model that can support the entire development lifecycle from compiling and packaging code to publishing websites. Gradle has been designed to support build automation across multiple languages and platforms including Java, Scala, Android, C/C++, and Groovy, and is closely integrated with development tools and continuous integration servers including Eclipse, IntelliJ, and Jenkins.
If you are mounting a volume and the uid/gid running Docker is not 1000, you should run as user root (-u root
).
root is also the default, so you can also simply not specify a user.
Run this from the directory of the Gradle project you want to build.
docker run --rm -u gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:latest gradle <gradle-task>
docker run --rm -u gradle -v "${pwd}:/home/gradle/project" -w /home/gradle/project gradle:latest gradle <gradle-task>
docker run --rm -u gradle -v "%cd%:/home/gradle/project" -w /home/gradle/project gradle:latest gradle <gradle-task>
Note the above command runs using uid/gid 1000 (user gradle) to avoid running as root.
The local Gradle cache can be reused across containers by creating a volume and mounting it to /home/gradle/.gradle. Note that sharing between concurrently running containers doesn't work currently (see #851).
Also, currently it's not possible to override the volume declaration of the parent.
So if you are using this image as a base image and want the Gradle cache to be written into the next layer, you will need to use a new user (or use the --gradle-user-home
/-g
argument) so that a new cache is created that isn't mounted to a volume.
docker volume create --name gradle-cache
docker run --rm -u gradle -v gradle-cache:/home/gradle/.gradle -v "$PWD":/home/gradle/project -w /home/gradle/project gradle:latest gradle <gradle-task>
- Run
update.sh
orupdate.ps1
. - Commit and push the changes.
- Update official-images (and docs if appropriate).