Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot 3.x/Spring Framework 6.x Support #13

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
764eede
Start work on moving to Spring 6+ and Spring Boot 3+
mattbertolini Jul 16, 2024
2359ab0
More updates for JDK 17 and Spring Boot 3.x
mattbertolini Jul 16, 2024
6464da4
Green build
mattbertolini Jul 16, 2024
5d7ab27
Start enforcing nullable annotations via NullAway
mattbertolini Jul 17, 2024
4b365aa
More NullAway support
mattbertolini Jul 18, 2024
44739b3
Gradle polish
mattbertolini Jul 18, 2024
4242f91
Gradle polish
mattbertolini Jul 18, 2024
1d6c55f
Gradle polish
mattbertolini Jul 18, 2024
9c5bd1f
Gradle polish
mattbertolini Jul 18, 2024
3569d9b
Gradle polish
mattbertolini Jul 18, 2024
7ada3ce
More NullAway support
mattbertolini Jul 18, 2024
d03ce0a
More NullAway support
mattbertolini Jul 19, 2024
2b83942
More NullAway support
mattbertolini Jul 19, 2024
270b27b
More NullAway support
mattbertolini Jul 19, 2024
d4e84c3
Docs updates
mattbertolini Jul 19, 2024
f3eb439
More NullAway support
mattbertolini Jul 22, 2024
e84cfe9
More NullAway support
mattbertolini Jul 22, 2024
d131ab0
More NullAway support
mattbertolini Jul 22, 2024
4e0bd4b
More NullAway support
mattbertolini Jul 22, 2024
4e6ef39
Add license plugin
mattbertolini Jul 23, 2024
679858c
Update license headers
mattbertolini Jul 23, 2024
02ecb7d
Disable license plugin
mattbertolini Jul 23, 2024
84f4f69
Fix workflow
mattbertolini Jul 23, 2024
74dc3e5
Fix issues
mattbertolini Jul 23, 2024
95b6fb5
Fix issues
mattbertolini Jul 23, 2024
ce2a473
Remove unused import
mattbertolini Jul 23, 2024
aa2ab9e
Update to record
mattbertolini Jul 23, 2024
55b86b1
Update constant usage
mattbertolini Jul 23, 2024
10a88ca
Remove unused methods
mattbertolini Jul 23, 2024
e4b4213
Remove unused imports
mattbertolini Jul 23, 2024
a483875
Add test for MapValueResolver
mattbertolini Jul 23, 2024
be435d1
Update version
mattbertolini Jul 23, 2024
6895cec
Update publish script
mattbertolini Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ indent_size = 4
indent_style = space
insert_final_newline = true

[*.java]
ij_java_class_count_to_use_import_on_demand = 999
ij_java_names_count_to_use_import_on_demand = 999

[*.{bat,cmd}]
end_of_line = crlf

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'
pull_request:
branches:
- $default-branch
- '*'

jobs:
build:
Expand Down
13 changes: 13 additions & 0 deletions LICENSE_HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright ${year} the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class ExampleConfiguration {

### Build Requirements

* Java 17 or above to build. The release jars are compiled to Java 8 bytecode. Integration tests are compiled to Java 17 bytecode.
* Java 17 or above to build and use.

To build:

Expand Down
8 changes: 7 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Release Notes

## 0.7.0-SNAPSHOT
## 1.0.0-SNAPSHOT
Released N/A

- Breaking change
- Updated to support Spring 6.x and Spring Boot 3.x. This brings with it a minimum Java version of 17. With the Spring
upgrade comes a switch to the Jakara EE Servlet API instead of Java EE.
- Update build to Gradle 8.9
- Added support for ErrorProne and NullAway for compile time checks of nullability.

## 0.6.0
Released 2023-12-01

Expand Down
4 changes: 1 addition & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ plugins {
}

allprojects {
apply(plugin = "com.mattbertolini.buildlogic.project-conventions")

group = "com.mattbertolini"
version = "0.7.0-SNAPSHOT"
version = "1.0.0-SNAPSHOT"
}

val rootJacocoDir = "reports/jacoco/testCodeCoverageReport"
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ plugins {
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.0.1")
implementation("gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mattbertolini.buildlogic

import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone

plugins {
id("net.ltgt.errorprone")
}

val libsCatalog = versionCatalogs.named("libs")
val errorProneCore = libsCatalog.findLibrary("errorProneCore").orElseThrow()
val errorProneAnnotations = libsCatalog.findLibrary("errorProneAnnotations").orElseThrow();
val nullAway = libsCatalog.findLibrary("nullAway").orElseThrow()
val nullAwayAnnotations = libsCatalog.findLibrary("nullAwayAnnotations").orElseThrow()

dependencies {
errorprone(errorProneCore)
errorprone(nullAway)
}

project.extensions.getByType<SourceSetContainer>().configureEach {
dependencies.add(compileOnlyConfigurationName, errorProneAnnotations)
dependencies.add(compileOnlyConfigurationName, nullAwayAnnotations)
}

tasks.withType<JavaCompile>().configureEach {
options.isFork = true
options.errorprone {
disableWarningsInGeneratedCode.set(true)
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "com.mattbertolini")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.mattbertolini.buildlogic
plugins {
java
jacoco
id("com.mattbertolini.buildlogic.project-conventions")
id("com.mattbertolini.buildlogic.error-prone")
}

val versionCatalog = versionCatalogs.named("libs")
Expand All @@ -13,10 +15,6 @@ java {
}
}

tasks.named<JavaCompile>("compileJava").configure {
options.release.set(8)
}

testing {
suites {
named<JvmTestSuite>("test").configure {
Expand All @@ -34,30 +32,25 @@ tasks.named<Jar>("jar").configure {
}
}

val springVersion: String = versionCatalog.findVersion("spring").orElseThrow().toString()
val springBootVersion: String = versionCatalog.findVersion("springBoot").orElseThrow().toString()

val javadocLinks = arrayOf(
"https://docs.oracle.com/javase/8/docs/api/",
"https://docs.oracle.com/javaee/7/api/",
"https://docs.spring.io/spring-framework/docs/$springVersion/javadoc-api/",
"https://docs.spring.io/spring-boot/docs/$springBootVersion/api/"
"https://docs.oracle.com/en/java/javase/17/docs/api",
"https://jakarta.ee/specifications/platform/11/apidocs/",
"https://docs.spring.io/spring-framework/docs/current/javadoc-api/",
"https://docs.spring.io/spring-boot/api/java/"
)

tasks.named<Javadoc>("javadoc").configure {
options {
this as StandardJavadocDocletOptions
source = "8"
source = "17"
links(*javadocLinks)
addStringOption("Xdoclint:none", "-quiet")
if (java.toolchain.languageVersion.get().asInt() >= 9) {
addBooleanOption("html5", true)
}
addBooleanOption("html5", true)
}
}

val jacocoVersion: String = versionCatalog.findVersion("jacoco").orElseThrow().toString()
configure<JacocoPluginExtension> {
jacoco {
toolVersion = jacocoVersion
}

Expand All @@ -69,4 +62,6 @@ tasks.named<JacocoReport>("jacocoTestReport").configure {
}
}

tasks.test { finalizedBy(tasks.jacocoTestReport) }
tasks.named("test").configure {
finalizedBy(tasks.named("jacocoTestReport"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ package com.mattbertolini.buildlogic

plugins {
`java-library`
id("com.mattbertolini.buildlogic.java-conventions")
}

apply(plugin = "com.mattbertolini.buildlogic.java-conventions")
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mattbertolini.buildlogic

import java.time.LocalDate

plugins {
id("com.github.hierynomus.license")
}

license {
mapping("java", "SLASHSTAR_STYLE")
header = isolated.rootProject.projectDirectory.file("LICENSE_HEADER.txt").asFile
ext.set("year", LocalDate.now().year)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.mattbertolini.buildlogic

//plugins {
// id("com.mattbertolini.buildlogic.license-conventions")
//}

// Configuring archive tasks to have repeatable builds
tasks.withType<AbstractArchiveTask>().configureEach {
isReproducibleFileOrder = true
Expand Down
6 changes: 5 additions & 1 deletion docs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ configurations {
dependencies {
implementation(project(":spring-webmvc-annotated-data-binder"))
implementation(project(":spring-webflux-annotated-data-binder"))
implementation(libs.javaxServletApi) // Version defined in Spring BOM file
implementation(libs.jakartaServletApi) // Version defined in Spring BOM file
compileOnly(libs.findbugsJsr305)

add("asciidoctorExt", libs.springAsciidoctorExtBlockSwitch)

testImplementation(libs.junitJupiterApi)
testImplementation(libs.assertJCore)
testImplementation(libs.mockitoCore)
testImplementation(libs.springTest)
testImplementation(libs.jakartaWebsocketApi)
testImplementation(libs.jakartaWebsocketClientApi)
testCompileOnly(libs.hamcrest) // Needed for Spring mock MVC matchers
testCompileOnly(libs.findbugsJsr305)
}

tasks.named<AsciidoctorTask>("asciidoctor").configure {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
/*
* Copyright 2019-2020 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.mattbertolini.spring.web.bind.docs;

import com.mattbertolini.spring.web.bind.annotation.BeanParameter;
Expand All @@ -25,6 +24,7 @@
import com.mattbertolini.spring.web.bind.annotation.RequestContext;
import com.mattbertolini.spring.web.bind.annotation.RequestParameter;
import com.mattbertolini.spring.web.bind.annotation.SessionParameter;
import org.springframework.lang.Nullable;

import java.time.ZoneId;
import java.util.Locale;
Expand All @@ -37,58 +37,68 @@ public class CustomRequestBean {
// end::class[]

// Query parameters
@Nullable
// tag::queryParam[]
@RequestParameter("different_name")
private String queryParam;

// end::queryParam[]

// Form data
@Nullable
// tag::formParam[]
@FormParameter("form_data")
private String formData;

// end::formParam[]

// HTTP headers
@Nullable
// tag::headerParam[]
@HeaderParameter("X-Custom-Header")
private String headerValues;

// end::headerParam[]

// Spring MVC/WebFlux path variables
@Nullable
// tag::pathParam[]
@PathParameter("pathParam")
private Integer pathParam;

// end::pathParam[]

// HTTP cookie values
@Nullable
// tag::cookieParam[]
@CookieParameter("cookie_value")
private String cookieValue;

// end::cookieParam[]

// HTTP session attributes
@Nullable
// tag::sessionParam[]
@SessionParameter("sessionAttribute")
private String sessionAttribute;

// end::sessionParam[]

// Spring derived request scoped data like locale and time zone
@Nullable
@RequestContext
private Locale locale;

@Nullable
@RequestContext
private ZoneId timeZone;

// A nested Java bean with additional annotated properties
@Nullable
@BeanParameter
private NestedBean nestedBean;

@Nullable
// tag::queryParam[]
public String getQueryParam() {
return queryParam;
Expand All @@ -99,6 +109,7 @@ public void setQueryParam(String queryParam) {
}
// end::queryParam[]

@Nullable
// tag::formParam[]
public String getFormData() {
return formData;
Expand All @@ -109,6 +120,7 @@ public void setFormData(String formData) {
}
// end::formParam[]

@Nullable
// tag::headerParam[]
public String getHeaderValues() {
return headerValues;
Expand All @@ -119,6 +131,7 @@ public void setHeaderValues(String headerValues) {
}
// end::headerParam[]

@Nullable
// tag::pathParam[]
public Integer getPathParam() {
return pathParam;
Expand All @@ -129,6 +142,7 @@ public void setPathParam(Integer pathParam) {
}
// end::pathParam[]

@Nullable
// tag::cookieParam[]
public String getCookieValue() {
return cookieValue;
Expand All @@ -139,6 +153,7 @@ public void setCookieValue(String cookieValue) {
}
// end::cookieParam[]

@Nullable
// tag::sessionParam[]
public String getSessionAttribute() {
return sessionAttribute;
Expand All @@ -149,6 +164,7 @@ public void setSessionAttribute(String sessionAttribute) {
}
// end::sessionParam[]

@Nullable
public Locale getLocale() {
return locale;
}
Expand All @@ -157,6 +173,7 @@ public void setLocale(Locale locale) {
this.locale = locale;
}

@Nullable
public ZoneId getTimeZone() {
return timeZone;
}
Expand All @@ -165,6 +182,7 @@ public void setTimeZone(ZoneId timeZone) {
this.timeZone = timeZone;
}

@Nullable
public NestedBean getNestedBean() {
return nestedBean;
}
Expand Down
Loading