From d3ce0eb0b20938b12b530b6533a4275dba8d6a99 Mon Sep 17 00:00:00 2001 From: Stefan Birkner Date: Fri, 16 Jul 2021 23:00:03 +0200 Subject: [PATCH] Add script for running Maven in Docker System Lambda cannot be build with newer JDKs, but some developers don't have JDK 8 installed anymore. The new scripts allows them to build System Lambda without having JDK 8 as long as they have Docker installed. --- .editorconfig | 2 +- README.md | 9 +++++++++ pom.xml | 2 +- scripts/mvn_in_docker.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 scripts/mvn_in_docker.sh diff --git a/.editorconfig b/.editorconfig index 6dc823c..9237973 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,6 @@ insert_final_newline = true tab_width = 4 trim_trailing_whitespace = true -[*.{xml,yml}] +[*.{sh,xml,yml}] indent_size = 2 indent_style = space diff --git a/README.md b/README.md index c3f2141..4d341c9 100644 --- a/README.md +++ b/README.md @@ -358,6 +358,15 @@ System Lambda supports [GitHub Actions](https://help.github.com/en/actions) integration. Your pull request will be automatically built by both CI servers. +### Build with Docker + +The script + + ./scripts/mvn_in_docker.sh clean verify -Dgpg.skip + +builds System Lambda inside a Docker container. It uses your Maven local +repository. This is helpful if you have a Linux or macOS without JDK 8. + ## Release Guide diff --git a/pom.xml b/pom.xml index d965d3f..19b45bc 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ system-lambda - 1.2.0 + 1.3.0-SNAPSHOT jar System Lambda diff --git a/scripts/mvn_in_docker.sh b/scripts/mvn_in_docker.sh new file mode 100755 index 0000000..e6e5eb8 --- /dev/null +++ b/scripts/mvn_in_docker.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# +# Executes Maven inside a Docker container with Java 8. The image has to be +# executed with options, phases and goals just like the original mvn command. +# E.g. instead of "mvn verify" you have to execute +# +# scripts/mvn_in_docker.sh verify +# +# from the project directory. The user's Maven local repository is used by the +# container. + +set -euxo pipefail + +readonly group=`id -g` +readonly user=`id -u` + +docker run \ + --rm \ + -e MAVEN_CONFIG=/var/maven/.m2 \ + -u "$user:$group" \ + -v "$(pwd)":/usr/src/system-lambda \ + -v ~/.m2:/var/maven/.m2 \ + -w /usr/src/system-lambda \ + maven:3.8.1-openjdk-8-slim \ + mvn -Duser.home=/var/maven "$@" +rm -r '?/' # I don't know why this directory is created.