Skip to content

Commit 4cfc23c

Browse files
committed
Fix version check
1 parent 9b92d85 commit 4cfc23c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

mvnw

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,25 @@ 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+
if echo $VERSION | egrep -q 'M|RC'; then
299+
echo Activating \"milestone\" profile for version=\"$VERSION\"
300+
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
301+
else
302+
echo Deactivating \"milestone\" profile for version=\"$VERSION\"
303+
echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
304+
fi
305+
306+
if echo $VERSION | egrep -q '[0-9]*\.[0-9]*\.[0-9]*$|RELEASE'; then
307+
echo Activating \"central\" profile for version=\"$VERSION\"
308+
echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pcentral"
309+
else
310+
echo Deactivating \"central\" profile for version=\"$VERSION\"
311+
echo $MAVEN_ARGS | grep -q central && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pcentral//')
312+
fi
313+
294314
clean || :
295-
exec_maven "$@"
315+
exec_maven "$MAVEN_ARGS" "$@"

0 commit comments

Comments
 (0)