master/scripts/build-plugin

39 lines
968 B
Bash
Executable File

#!/usr/bin/env bash
BUILDER_CONTAINER="rtyler/codevalet-builder"
if [ "${1}" = "" ]; then
echo "The path to a plugin must be passed as the first argument";
exit 1;
fi;
if [ ! -d $1 ]; then
echo "The path \`${1}\` is not a directory";
exit 1;
fi;
tty --quiet
if [ $? -eq 0 ]; then
TTY="-ti"
fi;
# Ensure ~/.m2 exists to avoid letting the Docker daemon create the directory
# owned by the root user
mkdir -p $HOME/.m2 $HOME/.npm $HOME/.cache
pushd $1
if [ -f pom.xml ]; then
echo ">> Building ${1}"
exec docker run --rm ${TTY} \
-u $(id -u):$(id -g) \
-e MAVEN_CONFIG=/var/maven/.m2 \
-v $HOME/.npm:/.npm \
-v $HOME/.cache:/.cache \
-v $HOME/.m2:/var/maven/.m2 \
-v $PWD:/data \
-w /data \
${BUILDER_CONTAINER} \
mvn -Duser.home=/var/maven -e -B -U -DskipTests install
fi;
popd