Skip to content

Commit 0687a3c

Browse files
committed
Fix version check
1 parent 9b92d85 commit 0687a3c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

mvnw

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,26 @@ verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291291
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292292
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
293293

294+
echo "Running version check"
295+
VERSION=$( sed '\!<parent!,\!</parent!d' `dirname $0`/pom.xml | grep '<version' | head -1 | sed -e 's/.*<version>//' -e 's!</version>.*$!!' )
296+
echo "The found version is [${VERSION}]"
297+
298+
MAVEN_ARGS=${MAVEN_ARGS:-}
299+
if echo $VERSION | egrep -q 'M|RC'; then
300+
echo Activating \"milestone\" profile for version=\"$VERSION\"
301+
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
302+
else
303+
echo Deactivating \"milestone\" profile for version=\"$VERSION\"
304+
echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
305+
fi
306+
307+
if echo $VERSION | egrep -q '[0-9]*\.[0-9]*\.[0-9]*$|RELEASE'; then
308+
echo Activating \"central\" profile for version=\"$VERSION\"
309+
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral"
310+
else
311+
echo Deactivating \"central\" profile for version=\"$VERSION\"
312+
echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//')
313+
fi
314+
294315
clean || :
295-
exec_maven "$@"
316+
exec_maven $MAVEN_ARGS "$@"

0 commit comments

Comments
 (0)