From b8f0a206f4271bf2fe2047387ea2e8d362d4e35b Mon Sep 17 00:00:00 2001 From: zzh Date: Sat, 22 Nov 2025 22:05:18 +0800 Subject: [PATCH 1/3] support Spring Boot 4.x and Spring Framework 7.x --- .github/workflows/gradle-publish.yml | 12 +-- build.gradle | 78 ++++++++++--------- gradle/wrapper/gradle-wrapper.properties | 4 +- struct-examples/build.gradle | 4 +- .../src/main/java/module-info.java | 1 + ...iceHealthContributorAutoConfiguration.java | 6 +- .../StructStoreServiceHealthIndicator.java | 4 +- ...StructStoreServiceHealthIndicatorTest.java | 8 +- struct-spring/build.gradle | 4 +- 9 files changed, 64 insertions(+), 57 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 71c7807..85f0c5e 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -17,16 +17,16 @@ jobs: packages: write steps: - - uses: actions/checkout@v4 - - name: Set up Microsoft OpenJDK 17 - uses: actions/setup-java@v4 + - uses: actions/checkout@v6 + - name: Set up Eclipse Temurin 25 + uses: actions/setup-java@v5 with: - java-version: '17' - distribution: 'microsoft' + java-version: '25' + distribution: 'temurin' cache: gradle - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 + uses: gradle/wrapper-validation-action@v3 - name: Build with Gradle run: ./gradlew --no-daemon --parallel build -x test diff --git a/build.gradle b/build.gradle index 190f36f..c802e7e 100644 --- a/build.gradle +++ b/build.gradle @@ -37,18 +37,18 @@ allprojects { apply plugin: 'java-library' ext.version_options = [ - SPRING_BOOT_VERSION: "3.1.5", - SPRING_VERSION : "6.0.13", - JETTY_VERSION : "9.4.44.v20210927", - MOCKITO_VERSION : "5.7.0", - JUNIT_VERSION : "5.9.3", + SPRING_BOOT_VERSION: "4.0.0", + SPRING_VERSION : "7.0.1", + JETTY_VERSION : "12.1.4", + MOCKITO_VERSION : "5.20.0", + JUNIT_VERSION : "6.0.1", + LOG4J2_VERSION : "2.25.2", + GSON_VERSION : "2.13.2", POI_VERSION : "5.2.2", - LOG4J2_VERSION : "2.20.0", - GSON_VERSION : "2.9.0", ] jacoco { - toolVersion = "0.8.8" + toolVersion = "0.8.14" } repositories { @@ -66,17 +66,21 @@ subprojects { apply plugin: 'idea' apply plugin: 'distribution' - sourceCompatibility = 17 - targetCompatibility = 17 - compileJava.options.setEncoding("UTF-8") - compileTestJava.options.setEncoding("UTF-8") + java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } + } + tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' + } group = "${rootProject.group}" version = "${rootProject.version}" dependencies { // slf4j - implementation('org.slf4j:slf4j-api:2.0.9') + implementation('org.slf4j:slf4j-api:2.0.17') // junit 5.x and mockito testImplementation("org.mockito:mockito-core:${version_options.MOCKITO_VERSION}") testImplementation("org.junit.jupiter:junit-jupiter:${version_options.JUNIT_VERSION}") @@ -93,15 +97,15 @@ subprojects { } distTar { - setArchivesBaseName("${project.name}") + archiveBaseName = project.name compression = Compression.GZIP - getArchiveExtension().set('tar.gz') + archiveExtension = 'tar.gz' } distributions { main { contents { - from project.tasks.withType(Jar) + from(tasks.jar) } } } @@ -120,11 +124,11 @@ task codeCoverageReport(type: JacocoReport) { } reports { - xml.enabled true - xml.destination file("${buildDir}/reports/report.xml") - html.enabled false - html.destination file("${buildDir}/reports/html") - csv.enabled false + xml.required = true + xml.outputLocation = file("${buildDir}/reports/report.xml") + html.required = false + html.outputLocation = file("${buildDir}/reports/html") + csv.required = false } afterEvaluate { @@ -169,22 +173,20 @@ Closure init_publish_module = { } } - model { - tasks.jar { - manifest { - attributes 'Implementation-Title': project.description ?: rootProject.description, - 'Implementation-Version': project.version, - 'Built-By': System.getProperty('user.name'), - 'Built-Date': new Date(), - 'Built-JDK': System.getProperty('java.version'), - 'Built-Gradle': gradle.gradleVersion, - 'Target-JDK': project.targetCompatibility - } - into("META-INF/maven/$project.group/$project.name") { - from { generatePomFileForMavenPublication } - rename ".*.xml", "pom.xml" - from generatePomPropertiesFile - } + tasks.named('jar') { + manifest { + attributes 'Implementation-Title': project.description ?: rootProject.description, + 'Implementation-Version': project.version, + 'Built-By': System.getProperty('user.name'), + 'Built-Date': new Date(), + 'Built-JDK': System.getProperty('java.version'), + 'Built-Gradle': gradle.gradleVersion, + 'Target-JDK': project.java.toolchain.languageVersion.map { it.asInt() }.get() + } + into("META-INF/maven/$project.group/$project.name") { + from { generatePomFileForMavenPublication } + rename ".*.xml", "pom.xml" + from generatePomPropertiesFile } } @@ -250,7 +252,7 @@ Closure init_publish_module = { } maven { name "gitea" - url = uri(project.findProperty("giteaMavenRepoUrl")) + url project.findProperty("giteaMavenRepoUrl") ?: "" credentials(HttpHeaderCredentials) { name = "Authorization" value = "token " + project.findProperty("giteaMavenAccessToken") diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f121fa3..cf25510 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip -rl=http\://192.168.0.2/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip +rl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/struct-examples/build.gradle b/struct-examples/build.gradle index 90e0ae4..d7c59b7 100644 --- a/struct-examples/build.gradle +++ b/struct-examples/build.gradle @@ -37,8 +37,8 @@ dependencies { implementation('mysql:mysql-connector-java:8.0.15') - implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.0") - implementation("com.sun.xml.bind:jaxb-impl:4.0.0") + implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.4") + implementation("com.sun.xml.bind:jaxb-impl:4.0.6") implementation("org.apache.logging.log4j:log4j-api:${version_options.LOG4J2_VERSION}") implementation("org.apache.logging.log4j:log4j-core:${version_options.LOG4J2_VERSION}") diff --git a/struct-spring-boot-starter/src/main/java/module-info.java b/struct-spring-boot-starter/src/main/java/module-info.java index 3d52f5c..861d3aa 100644 --- a/struct-spring-boot-starter/src/main/java/module-info.java +++ b/struct-spring-boot-starter/src/main/java/module-info.java @@ -18,4 +18,5 @@ requires spring.boot.actuator; requires spring.boot.actuator.autoconfigure; requires spring.boot.autoconfigure; + requires spring.boot.health; } \ No newline at end of file diff --git a/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthContributorAutoConfiguration.java b/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthContributorAutoConfiguration.java index f7b0a76..0240e61 100644 --- a/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthContributorAutoConfiguration.java +++ b/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthContributorAutoConfiguration.java @@ -18,11 +18,11 @@ package org.struct.spring.boot.autoconfigure; -import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration; -import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; -import org.springframework.boot.actuate.health.HealthEndpoint; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.health.actuate.endpoint.HealthEndpoint; +import org.springframework.boot.health.autoconfigure.contributor.CompositeHealthContributorConfiguration; +import org.springframework.boot.health.autoconfigure.contributor.ConditionalOnEnabledHealthIndicator; import org.springframework.context.annotation.Configuration; import org.struct.spring.support.StructStoreService; diff --git a/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicator.java b/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicator.java index 0e2f6b0..b8ba9bd 100644 --- a/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicator.java +++ b/struct-spring-boot-starter/src/main/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicator.java @@ -18,8 +18,8 @@ package org.struct.spring.boot.autoconfigure; -import org.springframework.boot.actuate.health.AbstractHealthIndicator; -import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.health.contributor.AbstractHealthIndicator; +import org.springframework.boot.health.contributor.Health; import org.struct.spring.support.StructBanner; import org.struct.spring.support.StructStoreService; diff --git a/struct-spring-boot-starter/src/test/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicatorTest.java b/struct-spring-boot-starter/src/test/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicatorTest.java index 4df3d58..8586fbd 100644 --- a/struct-spring-boot-starter/src/test/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicatorTest.java +++ b/struct-spring-boot-starter/src/test/java/org/struct/spring/boot/autoconfigure/StructStoreServiceHealthIndicatorTest.java @@ -19,10 +19,14 @@ package org.struct.spring.boot.autoconfigure; import org.junit.jupiter.api.Test; -import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.health.contributor.Health; import org.struct.spring.support.StructStoreService; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; /** * @author TinyZ. diff --git a/struct-spring/build.gradle b/struct-spring/build.gradle index b226852..7ce269e 100644 --- a/struct-spring/build.gradle +++ b/struct-spring/build.gradle @@ -23,8 +23,8 @@ dependencies { implementation("org.springframework:spring-core:${version_options.SPRING_VERSION}") implementation("org.springframework:spring-oxm:${version_options.SPRING_VERSION}") - implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.0") - implementation("com.sun.xml.bind:jaxb-impl:4.0.0") + implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.4") + implementation("com.sun.xml.bind:jaxb-impl:4.0.6") testImplementation("org.springframework:spring-test:${version_options.SPRING_VERSION}") } From 9392698f3ae07603e3e6022b052380759130e7d2 Mon Sep 17 00:00:00 2001 From: zzh Date: Sat, 22 Nov 2025 22:32:55 +0800 Subject: [PATCH 2/3] fix DataSourceAutoConfiguration --- struct-examples/src/main/java/org/struct/MyApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/struct-examples/src/main/java/org/struct/MyApplication.java b/struct-examples/src/main/java/org/struct/MyApplication.java index ffed106..60819d8 100644 --- a/struct-examples/src/main/java/org/struct/MyApplication.java +++ b/struct-examples/src/main/java/org/struct/MyApplication.java @@ -20,7 +20,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ImportResource; import org.struct.spring.support.StructStoreService; From 16631f1f85aa5696d7ca8b8a195e236c75e59679 Mon Sep 17 00:00:00 2001 From: zzh Date: Sun, 23 Nov 2025 13:35:08 +0800 Subject: [PATCH 3/3] fix junit 5.x --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index c802e7e..4994400 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,7 @@ subprojects { // junit 5.x and mockito testImplementation("org.mockito:mockito-core:${version_options.MOCKITO_VERSION}") testImplementation("org.junit.jupiter:junit-jupiter:${version_options.JUNIT_VERSION}") + testRuntimeOnly('org.junit.platform:junit-platform-launcher') // log4j 2.x testImplementation("org.apache.logging.log4j:log4j-api:${version_options.LOG4J2_VERSION}") testImplementation("org.apache.logging.log4j:log4j-core:${version_options.LOG4J2_VERSION}")