Skip to content

Instantly share code, notes, and snippets.

@onacit
Last active November 10, 2021 12:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onacit/036c93befff929a1f43b7603aa0b65bb to your computer and use it in GitHub Desktop.
Save onacit/036c93befff929a1f43b7603aa0b65bb to your computer and use it in GitHub Desktop.
Using docker for building a gradle project with alternative JDKs
#!/bin/sh
# https://gist.github.com/onacit/036c93befff929a1f43b7603aa0b65bb
if [ $# -lt 3 ]; then
echo "Usage: $0 <tag> <tasks...>, e.g. $0 6.0.1-jdk11 -Pprofile=local clean build"
echo "See https://hub.docker.com/_/gradle for available tags"
exit 1
fi
tag="$1"
shift
name=$(basename "$PWD")
docker run -it --rm -u gradle \
--name "$name" \
-v gradle_cache:/home/gradle/.gradle \
-v "$(pwd)":/usr/src/myproject \
-w /usr/src/myproject \
gradle:"$tag" gradle "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment