Skip to content

Instantly share code, notes, and snippets.

@lasp73
Last active October 2, 2020 12:36
Show Gist options
  • Save lasp73/8220897ee2cc77fb9d78d54cfdeeb0d9 to your computer and use it in GitHub Desktop.
Save lasp73/8220897ee2cc77fb9d78d54cfdeeb0d9 to your computer and use it in GitHub Desktop.
Compile using Maven inside Docker
#!/bin/bash
MVN_CMD="docker run -t --rm -u $(id -u $USER):$(id -g $USER) \
-v $HOME/.m2:/mnt/maven/.m2 \
-v $PWD:/mnt/code \
-w /mnt/code \
-e MAVEN_CONFIG=/mnt/maven/.m2 \
maven:3-jdk-8 mvn -Duser.home=/mnt/maven"
$MVN_CMD "$@"
@lasp73
Copy link
Author

lasp73 commented Nov 12, 2019

Build your Java project by executing: ./mvn-docker.sh clean package
This script reuses your Maven repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment