Skip to content

Commit 3fb6411

Browse files
committed
+ add jdk 17 in appveyor ubuntu CI
1 parent c1c1eea commit 3fb6411

File tree

7 files changed

+54
-21
lines changed

7 files changed

+54
-21
lines changed

library/scripts/run-junit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ source ./lib_common_build.sh
77
class_path="$(getClasspath)"
88
junit_test_cases="$(getJUnitTestCases)"
99
# shellcheck disable=SC2086
10-
runCmd "${JAVA_CMD[@]}" -cp "$class_path" \
10+
JAVA_CMD -cp "$class_path" \
1111
org.junit.runner.JUnitCore $junit_test_cases

scripts/codecov.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ source ./prepare-jdk.sh
1010
cd "$ROOT_PROJECT_DIR"
1111

1212
switch_to_jdk 11
13-
runCmd "${MVN_CMD[@]}" -Pgen-code-cov clean test jacoco:report
13+
MVN_CMD -Pgen-code-cov clean test jacoco:report
1414

1515
switch_to_jdk 8
1616
# use -Dmaven.main.skip option fix below problem of jacoco-maven-plugin:report :
1717
#
1818
# [WARNING] Classes in bundle 'Java Dns Cache Manipulator(DCM) Lib' do not match with execution data.
1919
# For report generation the same class files must be used as at runtime.
2020
# [WARNING] Execution data for class com/alibaba/xxx/Yyy does not match.
21-
runCmd "${MVN_CMD[@]}" -Pgen-code-cov -Dmaven.main.skip test jacoco:report coveralls:report
21+
MVN_CMD -Pgen-code-cov -Dmaven.main.skip test jacoco:report coveralls:report

scripts/common.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,20 @@ headInfo() {
6464
echo
6565
}
6666

67-
runCmd() {
67+
# How to compare a program's version in a shell script?
68+
# https://unix.stackexchange.com/questions/285924
69+
versionGreatEqThan() {
70+
(($# == 2)) || die "${FUNCNAME[0]} need only 2 arguments, actual arguments: $*"
71+
72+
local ver=$1
73+
local destVer=$2
74+
75+
[ "$ver" = "$destVer" ] && return 1
76+
77+
[ "$(printf '%s\n' "$ver" "$destVer" | sort -V | head -n1)" = "$destVer" ]
78+
}
79+
80+
logAndRun() {
6881
blueEcho "Run under work directory $PWD :$nl$*"
6982
time "$@"
7083
}

scripts/common_build.sh

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,46 @@ readonly ROOT_PROJECT_DIR="$(readlink -f "$ROOT_SCRIPTS_DIR/..")"
1919
readonly ROOT_PROJECT_VERSION=$(grep '<version>.*</version>' "$ROOT_PROJECT_DIR/pom.xml" | awk -F'</?version>' 'NR==1{print $2}')
2020
readonly ROOT_PROJECT_AID=$(grep '<artifactId>.*</artifactId>' "$ROOT_PROJECT_DIR/pom.xml" | awk -F'</?artifactId>' 'NR==1{print $2}')
2121

22+
#################################################################################
23+
# java operation functions
24+
#################################################################################
25+
26+
__getJavaVersion() {
27+
"$JAVA_HOME/bin/java" -version 2>&1 | awk -F\" '/ version "/{print $2}'
28+
}
29+
2230
# set env variable ENABLE_JAVA_RUN_DEBUG to enable java debug mode
23-
readonly -a JAVA_CMD=(
24-
"$JAVA_HOME/bin/java" -Xmx128m -Xms128m -server -ea -Duser.language=en -Duser.country=US
25-
${ENABLE_JAVA_RUN_VERBOSE_CLASS+ -verbose:class }
26-
${ENABLE_JAVA_RUN_DEBUG+ -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 }
27-
)
2831

29-
readonly -a MVN_CMD=(
30-
"$ROOT_PROJECT_DIR/mvnw" -V --no-transfer-progress
31-
)
32+
JAVA_CMD() {
33+
local additionalOptionsForJava11Plus
34+
versionGreatEqThan $(__getJavaVersion) 12 && additionalOptionsForJava11Plus=(
35+
--add-opens java.base/java.net=ALL-UNNAMED
36+
--add-opens java.base/sun.net=ALL-UNNAMED
37+
--add-opens java.base/sun.net.util=ALL-UNNAMED
38+
)
39+
40+
logAndRun "$JAVA_HOME/bin/java" -Xmx128m -Xms128m -server -ea -Duser.language=en -Duser.country=US \
41+
${ENABLE_JAVA_RUN_VERBOSE_CLASS+ -verbose:class} \
42+
${ENABLE_JAVA_RUN_DEBUG+ -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005} \
43+
${additionalOptionsForJava11Plus[@]:+"${additionalOptionsForJava11Plus[@]}"} \
44+
"$@"
45+
}
3246

3347
#################################################################################
3448
# maven operation functions
3549
#################################################################################
3650

51+
52+
MVN_CMD() {
53+
logAndRun "$ROOT_PROJECT_DIR/mvnw" -V --no-transfer-progress "$@"
54+
}
55+
3756
mvnClean() {
3857
checkNecessityForCallerFunction || return 0
3958

4059
(
4160
cd "$ROOT_PROJECT_DIR"
42-
runCmd "${MVN_CMD[@]}" clean || die "fail to mvn clean!"
61+
MVN_CMD clean || die "fail to mvn clean!"
4362
)
4463
}
4564

@@ -54,9 +73,9 @@ mvnBuildJar() {
5473
#
5574
# De-activate a maven profile from command line
5675
# https://stackoverflow.com/questions/25201430
57-
runCmd "${MVN_CMD[@]}" install -DperformRelease -P '!gen-sign' || die "fail to build jar!"
76+
MVN_CMD install -DperformRelease -P '!gen-sign' || die "fail to build jar!"
5877
else
59-
runCmd "${MVN_CMD[@]}" install -Dmaven.test.skip=true || die "fail to build jar!"
78+
MVN_CMD install -Dmaven.test.skip=true || die "fail to build jar!"
6079
fi
6180
)
6281
}
@@ -66,7 +85,7 @@ mvnCompileTest() {
6685

6786
(
6887
cd "$ROOT_PROJECT_DIR"
69-
runCmd "${MVN_CMD[@]}" test-compile || die "fail to compile test!"
88+
MVN_CMD test-compile || die "fail to compile test!"
7089
)
7190
}
7291

@@ -76,6 +95,6 @@ mvnCopyDependencies() {
7695
(
7796
cd "$ROOT_PROJECT_DIR"
7897
# https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
79-
runCmd "${MVN_CMD[@]}" dependency:copy-dependencies -DincludeScope=test -DexcludeArtifactIds=jsr305,spotbugs-annotations || die "fail to mvn copy-dependencies!"
98+
MVN_CMD dependency:copy-dependencies -DincludeScope=test -DexcludeArtifactIds=jsr305,spotbugs-annotations || die "fail to mvn copy-dependencies!"
8099
)
81100
}

scripts/integration-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ for jhome in "${java_home_var_names[@]}"; do
2525
export JAVA_HOME=${!jhome}
2626

2727
headInfo "test with Java: $JAVA_HOME"
28-
runCmd ../library/scripts/run-junit.sh skipClean
29-
runCmd ../tool/scripts/run-junit.sh skipClean
28+
logAndRun ../library/scripts/run-junit.sh skipClean
29+
logAndRun ../tool/scripts/run-junit.sh skipClean
3030
done

scripts/prepare-jdk.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jdks_install_by_sdkman=(
3737
6.0.119-zulu
3838
8.312.07.1-amzn
3939
11.0.12.7.1-ms
40+
17.0.1-ms
4041
)
4142
java_home_var_names=()
4243

@@ -65,7 +66,7 @@ __setJdkHomeVarsAndInstallJdk() {
6566
}
6667
fi
6768

68-
java_home_var_names=("${java_home_var_names[@]:+"${java_home_var_names[@]}"}" "$jdkHomeVarName")
69+
java_home_var_names=(${java_home_var_names[@]:+"${java_home_var_names[@]}"} "$jdkHomeVarName")
6970
printf '%s :\n\t%s\n\tspecified is %s\n' "$jdkHomeVarName" "${!jdkHomeVarName}" "$jdkNameOfSdkman"
7071
done
7172

tool/scripts/run-junit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ source ./tool_common_build.sh
77
class_path="$(getClasspath)"
88
junit_test_cases="$(getJUnitTestCases)"
99
# shellcheck disable=SC2086
10-
runCmd "${JAVA_CMD[@]}" -cp "$class_path" \
10+
JAVA_CMD -cp "$class_path" \
1111
org.junit.runner.JUnitCore $junit_test_cases

0 commit comments

Comments
 (0)