Skip to content

Commit 4f36abb

Browse files
authored
Merge pull request #54 from komamitsu/support-v3
Support tests using Spring Boot 3
2 parents 73caf0b + f945f91 commit 4f36abb

File tree

12 files changed

+176
-89
lines changed

12 files changed

+176
-89
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,86 @@ on:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
java_version: [11, 17]
1613
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up JDK ${{ matrix.java_version }}
19-
uses: actions/setup-java@v3
14+
- uses: actions/checkout@v4
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v4
2017
with:
2118
distribution: temurin
22-
java-version: ${{ matrix.java_version }}
23-
- name: Setup and execute Gradle 'check' task
24-
uses: gradle/gradle-build-action@v2
25-
with:
26-
arguments: check
19+
java-version: 11
20+
- name: Setup Gradle
21+
uses: gradle/actions/setup-gradle@v4
22+
- name: Execute Gradle 'check' task
23+
run: ./gradlew check
2724
- name: Upload Gradle test reports
28-
uses: actions/upload-artifact@v3
25+
uses: actions/upload-artifact@v4
2926
with:
3027
name: gradle_test_reports
3128
path: build/reports/tests/test
3229

3330
integration-test:
3431
runs-on: ubuntu-latest
35-
strategy:
36-
matrix:
37-
java_version: [11, 17]
3832
steps:
39-
- uses: actions/checkout@v3
40-
- name: Set up JDK ${{ matrix.java_version }}
41-
uses: actions/setup-java@v3
33+
- uses: actions/checkout@v4
34+
- name: Set up JDK 11
35+
uses: actions/setup-java@v4
4236
with:
4337
distribution: temurin
44-
java-version: ${{ matrix.java_version }}
45-
- name: Setup and execute Gradle 'integrationTest' task
46-
uses: gradle/gradle-build-action@v2
47-
with:
48-
arguments: integrationTest
38+
java-version: 11
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
- name: Execute Gradle 'integrationTest' task
42+
run: ./gradlew integrationTest
4943
- name: Upload Gradle test reports
50-
uses: actions/upload-artifact@v3
44+
uses: actions/upload-artifact@v4
5145
with:
5246
name: gradle_integration_test_reports
5347
path: build/reports/tests/integrationTest
5448

55-
test-on-example-app:
49+
test-on-example-app-with-spring-boot-2:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Set up JDK 11
54+
uses: actions/setup-java@v4
55+
with:
56+
distribution: temurin
57+
java-version: 11
58+
- name: Setup Gradle
59+
uses: gradle/actions/setup-gradle@v4
60+
- name: Install spring-data-sqlite to Maven local
61+
run: ./gradlew publishToMavenLocal
62+
- name: Execute the example app using Spring Boot 2 to test spring-data-sqlite
63+
working-directory: example
64+
env:
65+
WITH_SPRING_BOOT_2: true
66+
run: ./gradlew run
67+
68+
test-on-example-app-with-spring-boot-3:
5669
runs-on: ubuntu-latest
5770
strategy:
5871
matrix:
59-
java_version: [11, 17]
72+
java_version: [17, 21]
6073
steps:
61-
- uses: actions/checkout@v3
62-
- name: Set up JDK ${{ matrix.java_version }}
63-
uses: actions/setup-java@v3
74+
- uses: actions/checkout@v4
75+
- name: Set up JDK 11 to install spring-data-sqlite for `publishToMavenLocal`
76+
uses: actions/setup-java@v4
6477
with:
6578
distribution: temurin
66-
java-version: ${{ matrix.java_version }}
79+
java-version: 11
80+
- name: Setup Gradle
81+
uses: gradle/actions/setup-gradle@v4
6782
- name: Install spring-data-sqlite to Maven local
68-
uses: gradle/gradle-build-action@v2
83+
run: ./gradlew publishToMavenLocal
84+
- name: Set up JDK ${{ matrix.java_version }} for testing
85+
uses: actions/setup-java@v4
6986
with:
70-
arguments: publishToMavenLocal
71-
- name: Execute the example app to test spring-data-sqlite
72-
uses: gradle/gradle-build-action@v2
73-
with:
74-
build-root-directory: example
75-
arguments: run
76-
87+
distribution: temurin
88+
java-version: ${{ matrix.java_version }}
89+
- name: Setup Gradle
90+
uses: gradle/actions/setup-gradle@v4
91+
- name: Execute the example app using Spring Boot 3 to test spring-data-sqlite
92+
working-directory: example
93+
env:
94+
WITH_SPRING_BOOT_2: false
95+
run: ./gradlew run

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id "com.diffplug.spotless" version "6.25.0"
66
}
77

8-
project.version = '1.2.0'
8+
project.version = '1.3.0'
99
group = "org.komamitsu"
1010

1111
repositories {
@@ -120,7 +120,7 @@ spotless {
120120
java {
121121
importOrder()
122122
removeUnusedImports()
123-
googleJavaFormat('1.19.1')
123+
googleJavaFormat()
124124
formatAnnotations()
125125
}
126126
}

example/build.gradle

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
plugins {
22
id 'java-library'
33
id 'application'
4-
id "com.diffplug.spotless" version "6.12.1"
4+
id "com.diffplug.spotless" version "6.25.0"
55
}
66

77
group 'org.komamitsu'
88
version '1.0-SNAPSHOT'
99

1010
def springDataSqliteVersion = getSpringDataSqliteVersion()
11+
def withSpringBoot2 = System.getenv('WITH_SPRING_BOOT_2')?.toBoolean() ?: false
12+
if (withSpringBoot2) {
13+
println("Testing with Spring Boot 2")
14+
}
15+
else {
16+
println("Testing with Spring Boot 3")
17+
}
1118

1219
repositories {
1320
mavenCentral()
@@ -16,14 +23,37 @@ repositories {
1623

1724
dependencies {
1825
implementation "org.komamitsu:spring-data-sqlite:${springDataSqliteVersion}"
19-
implementation 'org.springframework.boot:spring-boot-starter:2.7.6'
20-
implementation 'org.springframework.boot:spring-boot-starter-aop:2.7.6'
26+
if (withSpringBoot2) {
27+
implementation platform('org.springframework.boot:spring-boot-dependencies:2.7.18')
28+
} else {
29+
implementation platform('org.springframework.boot:spring-boot-dependencies:3.3.5')
30+
}
31+
implementation 'org.springframework.boot:spring-boot-starter'
32+
implementation 'org.springframework.boot:spring-boot-starter-aop'
2133
implementation 'org.springframework.retry:spring-retry:1.3.4'
2234
implementation 'com.zaxxer:HikariCP:4.0.3'
35+
implementation('org.slf4j:slf4j-api') {
36+
if (withSpringBoot2) {
37+
version {
38+
// This version of spring-boot-starter-logging uses logback-classic:1.2.x.
39+
// But Spring Data JDBC for SQLite uses slf4j-api:2.x and Spring logging doesn't work.
40+
// So we specify a proper version here.
41+
strictly '1.7.36'
42+
}
43+
}
44+
}
2345
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
2446
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
2547
}
2648

49+
compileJava {
50+
if (!withSpringBoot2) {
51+
// This is needed only for Spring Boot 3.
52+
// It will be not needed later https://stackoverflow.com/questions/78374721/spring-data-jdbc-repository-bean-creation-error/78376635#comment138178415_78376635.
53+
options.compilerArgs << '-parameters'
54+
}
55+
}
56+
2757
test {
2858
useJUnitPlatform()
2959
}
@@ -36,7 +66,7 @@ spotless {
3666
java {
3767
importOrder()
3868
removeUnusedImports()
39-
googleJavaFormat('1.7')
69+
googleJavaFormat()
4070
formatAnnotations()
4171
}
4272
}
-15.9 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

example/gradlew

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +82,12 @@ do
8082
esac
8183
done
8284

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
85+
# This is normally unused
86+
# shellcheck disable=SC2034
8687
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90+
' "$PWD" ) || exit
9091

9192
# Use the maximum available, or set MAX_FD != -1 to use that value.
9293
MAX_FD=maximum
@@ -133,22 +134,29 @@ location of your Java installation."
133134
fi
134135
else
135136
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
if ! command -v java >/dev/null 2>&1
138+
then
139+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137140
138141
Please set the JAVA_HOME variable in your environment to match the
139142
location of your Java installation."
143+
fi
140144
fi
141145

142146
# Increase the maximum file descriptors if we can.
143147
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144148
case $MAX_FD in #(
145149
max*)
150+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151+
# shellcheck disable=SC2039,SC3045
146152
MAX_FD=$( ulimit -H -n ) ||
147153
warn "Could not query maximum file descriptor limit"
148154
esac
149155
case $MAX_FD in #(
150156
'' | soft) :;; #(
151157
*)
158+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159+
# shellcheck disable=SC2039,SC3045
152160
ulimit -n "$MAX_FD" ||
153161
warn "Could not set maximum file descriptor limit to $MAX_FD"
154162
esac
@@ -193,18 +201,28 @@ if "$cygwin" || "$msys" ; then
193201
done
194202
fi
195203

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
204+
205+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207+
208+
# Collect all arguments for the java command:
209+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210+
# and any embedded shellness will be escaped.
211+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212+
# treated as '${Hostname}' itself on the command line.
201213

202214
set -- \
203215
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204216
-classpath "$CLASSPATH" \
205217
org.gradle.wrapper.GradleWrapperMain \
206218
"$@"
207219

220+
# Stop when "xargs" is not available.
221+
if ! command -v xargs >/dev/null 2>&1
222+
then
223+
die "xargs is not available"
224+
fi
225+
208226
# Use "xargs" to parse quoted args.
209227
#
210228
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

0 commit comments

Comments
 (0)