Skip to content

Commit c206215

Browse files
authored
Merge pull request #56 from komamitsu/build-with-spring-data-jdbc-v3
Build library using Spring Data JDBC v3
2 parents 68ff728 + d1ce72d commit c206215

File tree

3 files changed

+43
-81
lines changed

3 files changed

+43
-81
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,86 +10,66 @@ on:
1010
jobs:
1111
build:
1212
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
java_version: [17, 21]
1316
steps:
1417
- uses: actions/checkout@v4
15-
- name: Set up JDK 11
18+
- name: Set up JDK ${{ matrix.java_version }}
1619
uses: actions/setup-java@v4
1720
with:
1821
distribution: temurin
19-
java-version: 11
22+
java-version: ${{ matrix.java_version }}
2023
- name: Setup Gradle
2124
uses: gradle/actions/setup-gradle@v4
2225
- name: Execute Gradle 'check' task
2326
run: ./gradlew check
2427
- name: Upload Gradle test reports
2528
uses: actions/upload-artifact@v4
2629
with:
27-
name: gradle_test_reports
30+
name: gradle_test_reports_with_java_${{ matrix.java_version }}
2831
path: build/reports/tests/test
2932

3033
integration-test:
3134
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
java_version: [17, 21]
3238
steps:
3339
- uses: actions/checkout@v4
34-
- name: Set up JDK 11
40+
- name: Set up JDK ${{ matrix.java_version }}
3541
uses: actions/setup-java@v4
3642
with:
3743
distribution: temurin
38-
java-version: 11
44+
java-version: ${{ matrix.java_version }}
3945
- name: Setup Gradle
4046
uses: gradle/actions/setup-gradle@v4
4147
- name: Execute Gradle 'integrationTest' task
4248
run: ./gradlew integrationTest
4349
- name: Upload Gradle test reports
4450
uses: actions/upload-artifact@v4
4551
with:
46-
name: gradle_integration_test_reports
52+
name: gradle_integration_test_reports_with_java_${{ matrix.java_version }}
4753
path: build/reports/tests/integrationTest
4854

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:
55+
test-on-example-app:
6956
runs-on: ubuntu-latest
7057
strategy:
7158
matrix:
7259
java_version: [17, 21]
7360
steps:
7461
- uses: actions/checkout@v4
75-
- name: Set up JDK 11 to install spring-data-sqlite for `publishToMavenLocal`
62+
- name: Set up JDK ${{ matrix.java_version }}
7663
uses: actions/setup-java@v4
7764
with:
7865
distribution: temurin
79-
java-version: 11
66+
java-version: ${{ matrix.java_version }}
8067
- name: Setup Gradle
8168
uses: gradle/actions/setup-gradle@v4
8269
- name: Install spring-data-sqlite to Maven local
8370
run: ./gradlew publishToMavenLocal
84-
- name: Set up JDK ${{ matrix.java_version }} for testing
85-
uses: actions/setup-java@v4
86-
with:
87-
distribution: temurin
88-
java-version: ${{ matrix.java_version }}
8971
- name: Setup Gradle
9072
uses: gradle/actions/setup-gradle@v4
91-
- name: Execute the example app using Spring Boot 3 to test spring-data-sqlite
73+
- name: Execute the example app using Spring Boot to test spring-data-sqlite
9274
working-directory: example
93-
env:
94-
WITH_SPRING_BOOT_2: false
9575
run: ./gradlew run

build.gradle

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

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

1111
repositories {
1212
mavenCentral()
1313
}
1414

15-
tasks.withType(Test) {
16-
useJUnitPlatform()
17-
}
18-
1915
java {
2016
withJavadocJar()
2117
withSourcesJar()
@@ -38,21 +34,37 @@ configurations {
3834
integrationTestCompileOnly.extendsFrom testCompileOnly
3935
}
4036

41-
4237
dependencies {
4338
implementation "org.slf4j:slf4j-api:2.0.11"
44-
implementation 'javax.annotation:javax.annotation-api:1.3.2'
45-
api "org.springframework.data:spring-data-jdbc:2.4.5"
46-
implementation 'org.xerial:sqlite-jdbc:3.45.1.0'
39+
implementation "javax.annotation:javax.annotation-api:1.3.2"
40+
implementation platform("org.springframework.boot:spring-boot-dependencies:3.3.5")
41+
api "org.springframework.data:spring-data-jdbc"
42+
implementation "org.xerial:sqlite-jdbc:3.45.1.0"
4743
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.1"
4844
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.2"
4945
testImplementation "org.assertj:assertj-core:3.25.3"
5046
testImplementation "org.mockito:mockito-core:5.11.0"
5147
testImplementation "org.mockito:mockito-junit-jupiter:5.9.0"
52-
testImplementation "org.springframework.boot:spring-boot-starter-test:2.7.6"
48+
testImplementation "org.springframework.boot:spring-boot-starter-test"
5349
integrationTestImplementation "com.zaxxer:HikariCP:5.1.0"
5450
}
5551

52+
tasks.withType(Test) {
53+
useJUnitPlatform()
54+
}
55+
56+
tasks.register('integrationTest', Test) {
57+
description = 'Runs the integration tests'
58+
group = 'verification'
59+
testClassesDirs = sourceSets.integrationTest.output.classesDirs
60+
classpath = sourceSets.integrationTest.runtimeClasspath
61+
outputs.upToDateWhen { false } // ensures integration tests are run every time when called
62+
}
63+
64+
compileIntegrationTestJava {
65+
options.compilerArgs << "-parameters"
66+
}
67+
5668
publishing {
5769
publications {
5870
mavenJava(MavenPublication) {
@@ -124,11 +136,3 @@ spotless {
124136
formatAnnotations()
125137
}
126138
}
127-
128-
task integrationTest(type: Test) {
129-
description = 'Runs the integration tests'
130-
group = 'verification'
131-
testClassesDirs = sourceSets.integrationTest.output.classesDirs
132-
classpath = sourceSets.integrationTest.runtimeClasspath
133-
outputs.upToDateWhen { false } // ensures integration tests are run every time when called
134-
}

example/build.gradle

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ 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-
}
1811

1912
repositories {
2013
mavenCentral()
@@ -23,35 +16,20 @@ repositories {
2316

2417
dependencies {
2518
implementation "org.komamitsu:spring-data-sqlite:${springDataSqliteVersion}"
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-
}
19+
implementation platform('org.springframework.boot:spring-boot-dependencies:3.3.5')
3120
implementation 'org.springframework.boot:spring-boot-starter'
3221
implementation 'org.springframework.boot:spring-boot-starter-aop'
3322
implementation 'org.springframework.retry:spring-retry:1.3.4'
3423
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-
}
24+
implementation 'org.slf4j:slf4j-api'
4525
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
4626
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
4727
}
4828

4929
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-
}
30+
// This is needed when using Spring Boot 3.
31+
// See https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-6.1-Release-Notes#parameter-name-retention for detail.
32+
options.compilerArgs << '-parameters'
5533
}
5634

5735
test {

0 commit comments

Comments
 (0)