Last active
December 16, 2021 03:12
-
-
Save onacit/9f79215aaf6bd8d59e78ed6a38b93889 to your computer and use it in GitHub Desktop.
Using docker for building a maven project with alternative JDKs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://gist.github.com/onacit/9f79215aaf6bd8d59e78ed6a38b93889 | |
# https://stackoverflow.com/questions/3545292/how-to-get-maven-project-version-to-the-bash-command-line | |
if [ $# -lt 2 ]; then | |
echo "Usage: $0 <tag> <phases...>, e.g. $0 3-jdk-11-openj9 clean install" | |
echo "See https://hub.docker.com/_/maven for available tags" | |
exit 1 | |
fi | |
groupId=$(mvn help:evaluate -Dexpression=project.groupId | grep -v '\[') | |
artifactId=$(mvn help:evaluate -Dexpression=project.artifactId | grep -v '\[') | |
version=$(mvn help:evaluate -Dexpression=project.version | grep -v '\[') | |
tag="$1" | |
shift | |
docker run -it --rm \ | |
--name "$artifactId" \ | |
## -v "$HOME/.m2":/root/.m2 \ | |
-v "$HOME/.m2/repository":/root/.m2/repository \ | |
-v "$HOME/.m2/settings.xml":/root/.m2/settings.xml \ | |
-v "$(pwd)":/usr/src/"$groupId"/"$artifactId"/"$version" \ | |
-w /usr/src/"$groupId"/"$artifactId"/"$version" \ | |
maven:"$tag" mvn "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment