Skip to content

Commit

Permalink
! fix build fail caused by -DperformRelease
Browse files Browse the repository at this point in the history
skip options

- for sample/archetype:generate projects
- when not jdk 11
  • Loading branch information
oldratlee committed Jan 7, 2021
1 parent 6b3dfe3 commit 9c0c914
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
12 changes: 12 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ headInfo() {
colorEcho "0;34;46" ================================================================================
}

# How to compare a program's version in a shell script?
# https://unix.stackexchange.com/questions/285924
versionLessThan() {
(($# == 2)) || die "versionLessThan must 2 arguments"
local ver=$1
local destVer=$2

[ "$ver" = "$destVer" ] && return 0

[ "$(printf '%s\n' "$ver" "$destVer" | sort -V | head -n1)" = "$ver" ]
}

logAndRun() {
local simple_mode=false
[ "$1" = "-s" ] && {
Expand Down
36 changes: 29 additions & 7 deletions scripts/common_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ source "$(dirname "$(readlink -f "$BASH_SOURCE")")/common.sh"
# build util functions
################################################################################

readonly -a MVN_OPTIONS=(
-V --no-transfer-progress
-DperformRelease -P'!gen-sign'
)

MVN() {
__getMvnwExe() {
local maven_wrapper_name="mvnw"

local d="$PWD"
Expand All @@ -24,7 +19,34 @@ MVN() {
d=$(dirname "$d")
done

logAndRun "$d/$maven_wrapper_name" "${MVN_OPTIONS[@]}" "$@"
echo "$d/$maven_wrapper_name"
}

__getJavaVersion() {
cd $(dirname "$(readlink -f "$BASH_SOURCE")")/../cola-components/ &&
./mvnw -v | awk -F': |,' '/^Java version/ {print $2}'
}

getMoreMvnOptionsWhenJdk11() {
if ! versionLessThan $(__getJavaVersion) 11 && versionLessThan $(__getJavaVersion) 12; then
echo -DperformRelease -P'!gen-sign'
fi
}

readonly -a _MVN_BASIC_OPTIONS=(
-V --no-transfer-progress
)
readonly -a _MVN_OPTIONS=(
"${_MVN_BASIC_OPTIONS[@]}"
$(getMoreMvnOptionsWhenJdk11)
)

MVN() {
logAndRun "$(__getMvnwExe)" "${_MVN_OPTIONS[@]}" "$@"
}

MVN_WITH_BASIC_OPTIONS() {
logAndRun "$(__getMvnwExe)" "${_MVN_BASIC_OPTIONS[@]}" "$@"
}

# Where is Maven local repository?
Expand Down
6 changes: 3 additions & 3 deletions scripts/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cleanMavenInstallOfColaInMavenLocalRepository
-DinteractiveMode=false

cd "$artifactId"
MVN install
MVN_WITH_BASIC_OPTIONS install
)

(
Expand Down Expand Up @@ -88,12 +88,12 @@ cleanMavenInstallOfColaInMavenLocalRepository
-DinteractiveMode=false

cd "$artifactId"
MVN install
MVN_WITH_BASIC_OPTIONS install
)

(
headInfo "CI: sample/craftsman"

cd sample/craftsman/
MVN clean install
MVN_WITH_BASIC_OPTIONS clean install
)

0 comments on commit 9c0c914

Please sign in to comment.