| ########################################################################################## |
| # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central |
| # This allows using the maven wrapper in projects that prohibit checking in binary data. |
| ########################################################################################## |
| if [ -r "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" ]; then |
| if [ "$MVNW_VERBOSE" = true ]; then |
| echo "Found .mvn/wrapper/maven-wrapper.jar" |
| fi |
| else |
| if [ "$MVNW_VERBOSE" = true ]; then |
| echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." |
| fi |
| |
| jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" |
| |
| if [ -n "$MVNW_REPOURL" ]; then |
| jarUrl="$MVNW_REPOURL/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" |
| fi |
| |
| if [ "$MVNW_VERBOSE" = true ]; then |
| echo "Downloading from: $jarUrl" |
| fi |
| wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" |
| if $cygwin; then |
| wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` |
| fi |
| |
| if [ `echo "${jarUrl}" | cut -c 1-4` != 'file' ] && command -v wget > /dev/null; then |
| if [ "$MVNW_VERBOSE" = true ]; then |
| echo "Found wget ... using wget" |
| fi |
| if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
| wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" |
| else |
| wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" |
| fi |
| elif command -v curl > /dev/null; then |
| if [ "$MVNW_VERBOSE" = true ]; then |
| echo "Found curl ... using curl" |
| fi |
| if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
| curl --location -o "$wrapperJarPath" "$jarUrl" -f |
| else |
| curl --location --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f |
| fi |
| fi |
| fi |
| ########################################################################################## |
| # End of extension |
| ########################################################################################## |
| |