Skip to content

Commit c07ac4f

Browse files
committed
Support test using Spring Boot 3
1 parent 73caf0b commit c07ac4f

File tree

4 files changed

+75
-23
lines changed

4 files changed

+75
-23
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ on:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
java_version: [11, 17]
1613
steps:
1714
- uses: actions/checkout@v3
18-
- name: Set up JDK ${{ matrix.java_version }}
15+
- name: Set up JDK 11
1916
uses: actions/setup-java@v3
2017
with:
2118
distribution: temurin
22-
java-version: ${{ matrix.java_version }}
19+
java-version: 11
2320
- name: Setup and execute Gradle 'check' task
2421
uses: gradle/gradle-build-action@v2
2522
with:
@@ -32,16 +29,13 @@ jobs:
3229

3330
integration-test:
3431
runs-on: ubuntu-latest
35-
strategy:
36-
matrix:
37-
java_version: [11, 17]
3832
steps:
3933
- uses: actions/checkout@v3
40-
- name: Set up JDK ${{ matrix.java_version }}
34+
- name: Set up JDK 11
4135
uses: actions/setup-java@v3
4236
with:
4337
distribution: temurin
44-
java-version: ${{ matrix.java_version }}
38+
java-version: 11
4539
- name: Setup and execute Gradle 'integrationTest' task
4640
uses: gradle/gradle-build-action@v2
4741
with:
@@ -52,25 +46,52 @@ jobs:
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@v3
53+
- name: Set up JDK 11
54+
uses: actions/setup-java@v3
55+
with:
56+
distribution: temurin
57+
java-version: 11
58+
- name: Install spring-data-sqlite to Maven local
59+
uses: gradle/gradle-build-action@v2
60+
with:
61+
arguments: publishToMavenLocal
62+
- name: Execute the example app using Spring Boot 2 to test spring-data-sqlite
63+
uses: gradle/gradle-build-action@v2
64+
with:
65+
build-root-directory: example
66+
arguments: run
67+
env:
68+
WITH_SPRING_BOOT_2: true
69+
70+
test-on-example-app-with-spring-boot-3:
5671
runs-on: ubuntu-latest
5772
strategy:
5873
matrix:
59-
java_version: [11, 17]
74+
java_version: [17, 21]
6075
steps:
6176
- uses: actions/checkout@v3
62-
- name: Set up JDK ${{ matrix.java_version }}
77+
- name: Set up JDK 11 to install spring-data-sqlite for `publishToMavenLocal`
6378
uses: actions/setup-java@v3
6479
with:
6580
distribution: temurin
66-
java-version: ${{ matrix.java_version }}
81+
java-version: 11
6782
- name: Install spring-data-sqlite to Maven local
6883
uses: gradle/gradle-build-action@v2
6984
with:
7085
arguments: publishToMavenLocal
71-
- name: Execute the example app to test spring-data-sqlite
86+
- name: Set up JDK ${{ matrix.java_version }} for testing
87+
uses: actions/setup-java@v3
88+
with:
89+
distribution: temurin
90+
java-version: ${{ matrix.java_version }}
91+
- name: Execute the example app using Spring Boot 3 to test spring-data-sqlite
7292
uses: gradle/gradle-build-action@v2
7393
with:
7494
build-root-directory: example
7595
arguments: run
76-
96+
env:
97+
WITH_SPRING_BOOT_2: false

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
}

src/main/java/org/komamitsu/spring/data/sqlite/SqliteRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
* @param <ID> an identifier class
1919
*/
2020
@NoRepositoryBean
21-
public interface SqliteRepository<T, ID> extends PagingAndSortingRepository<T, ID> {
21+
public interface SqliteRepository<T, ID>
22+
extends PagingAndSortingRepository<T, ID>, CrudRepository<T, ID> {
2223
T insert(T instance);
2324

2425
T update(T instance);

0 commit comments

Comments
 (0)