-
Notifications
You must be signed in to change notification settings - Fork 4
/
mvnww
executable file
·29 lines (21 loc) · 977 Bytes
/
mvnww
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -euo pipefail
# This script download through a proxy the zip distribution of Maven
# drops it on the local filesystem and executes subsequent ./mvnw commands accordingly
#
# USAGE: `export M2_HOME=$(./mvnww)`
# and use ./mvnw for all of the following Maven commands
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
MAVEN_WRAPPER_PROPERTIES="$SCRIPT_DIR/.mvn/wrapper/maven-wrapper.properties"
MAVEN_ZIP_TARGET="$SCRIPT_DIR/.mvn/wrapper/apache-maven-bin.zip"
curl -sL \
"$(cat ${MAVEN_WRAPPER_PROPERTIES} | grep "distributionUrl" | sed s'/distributionUrl=//')" \
--output $MAVEN_ZIP_TARGET
cp "$MAVEN_WRAPPER_PROPERTIES" "$MAVEN_WRAPPER_PROPERTIES.backup"
echo "distributionUrl=file://$MAVEN_ZIP_TARGET" > $MAVEN_WRAPPER_PROPERTIES
mkdir -p $HOME/.m2
# Fallback to default location
M2_HOME="${M2_HOME:-/usr/share/maven}"
cp $M2_HOME/conf/settings.xml $HOME/.m2
./mvnw --version > /dev/null 2> /dev/null
echo "$HOME/.m2"