Skip to content

Commit

Permalink
support for MAVEN_ARGS variable for mvn 3.x (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Feb 4, 2022
1 parent e49a1ea commit 7b08f34
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions scripts/src/main/resources/scripts/command/mvn
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ if [ -n "${DEVON_IDE_TRACE}" ]; then set -vx; fi
# shellcheck source=scripts/functions
source "$(dirname "${0}")"/../functions

function doGetMavenVersion() {
echo "${MAVEN_VERSION:-3.8.1}"
}

# $1: optional setup
function doSetup() {
doDevonCommand java setup silent
if [ "${1}" != "silent" ] || [ ! -d "${MAVEN_HOME}" ]
then
local version=${MAVEN_VERSION:-3.8.1}
doInstall "-" "${MAVEN_HOME}" "maven" "${version}" "" "" "-"
doInstall "-" "${MAVEN_HOME}" "maven" "$(doGetMavenVersion)" "" "" "-"
fi
if [ "${1}" != "silent" ]
then
Expand Down Expand Up @@ -303,21 +306,40 @@ function doCheckNoSnapshots() {

function doRunBuild() {
local maven_cmd="${MVN}"
local maven_arguments=""
if [ -x mvnw ]
then
maven_cmd="./mvnw"
else
doSetup silent
fi
doEcho "Running: ${maven_cmd} ${*}"
if [ -n "${MAVEN_ARGS}" ]
then
doVersionCompare "$(doGetMavenVersion)" "4.0"
if [ "${?}" == 2 ]
then
# Maven version is lower than 4.0 (3.x)
maven_arguments="${MAVEN_ARGS}"
fi
fi
if doIsQuiet
then
"${maven_cmd}" -q "${@}"
exit ${?}
if [ -n "${maven_arguments}" ]
then
maven_arguments="-q ${maven_arguments}"
else
maven_arguments="-q"
fi
fi
if [ -n "${maven_arguments}" ]
then
doEcho "Running: ${maven_cmd} ${maven_arguments} ${*}"
"${maven_cmd}" "${maven_arguments}" "${@}"
else
doEcho "Running: ${maven_cmd} ${*}"
"${maven_cmd}" "${@}"
exit ${?}
fi
exit ${?}
}

# CLI
Expand Down

0 comments on commit 7b08f34

Please sign in to comment.