Skip to content

Commit aa94593

Browse files
authored
Merge branch 'spring-projects:main' into main
2 parents 0bf4234 + b8cdef6 commit aa94593

File tree

409 files changed

+3975
-12685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+3975
-12685
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ atlassian-ide-plugin.xml
5353
cached-antora-playbook.yml
5454

5555
node_modules
56+
/.kotlin/

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ configure([rootProject] + javaProjects) { project ->
8989

9090
ext.javadocLinks = [
9191
"https://docs.oracle.com/en/java/javase/17/docs/api/",
92-
"https://jakarta.ee/specifications/platform/9/apidocs/",
92+
"https://jakarta.ee/specifications/platform/11/apidocs/",
9393
"https://docs.jboss.org/hibernate/orm/5.6/javadocs/",
9494
"https://eclipse.dev/aspectj/doc/released/aspectj5rt-api",
9595
"https://www.quartz-scheduler.org/api/2.3.0/",

buildSrc/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ The `org.springframework.build.conventions` plugin applies all conventions to th
1111
* Configuring the Kotlin compiler, see `KotlinConventions`
1212
* Configuring testing in the build with `TestConventions`
1313

14+
This plugin also provides a DSL extension to optionally enable Java preview features for
15+
compiling and testing sources in a module. This can be applied with the following in a
16+
module build file:
17+
18+
```groovy
19+
springFramework {
20+
enableJavaPreviewFeatures = true
21+
}
22+
```
23+
1424

1525
## Build Plugins
1626

buildSrc/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ext {
2020
dependencies {
2121
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
2222
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
23-
implementation "org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}"
2423
implementation "org.gradle:test-retry-gradle-plugin:1.5.6"
2524
implementation "io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}"
2625
implementation "io.spring.nohttp:nohttp-gradle:0.0.11"

buildSrc/src/main/java/org/springframework/build/ConventionsPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ConventionsPlugin implements Plugin<Project> {
3636

3737
@Override
3838
public void apply(Project project) {
39+
project.getExtensions().create("springFramework", SpringFrameworkExtension.class);
3940
new CheckstyleConventions().apply(project);
4041
new JavaConventions().apply(project);
4142
new KotlinConventions().apply(project);

buildSrc/src/main/java/org/springframework/build/JavaConventions.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,25 @@ private void applyJavaCompileConventions(Project project) {
7575
toolchain.getVendor().set(JvmVendorSpec.BELLSOFT);
7676
toolchain.getLanguageVersion().set(JavaLanguageVersion.of(17));
7777
});
78-
project.getTasks().withType(JavaCompile.class)
79-
.matching(compileTask -> compileTask.getName().equals(JavaPlugin.COMPILE_JAVA_TASK_NAME))
80-
.forEach(compileTask -> {
81-
compileTask.getOptions().setCompilerArgs(COMPILER_ARGS);
82-
compileTask.getOptions().setEncoding("UTF-8");
83-
});
84-
project.getTasks().withType(JavaCompile.class)
85-
.matching(compileTask -> compileTask.getName().equals(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
86-
|| compileTask.getName().equals("compileTestFixturesJava"))
87-
.forEach(compileTask -> {
88-
compileTask.getOptions().setCompilerArgs(TEST_COMPILER_ARGS);
89-
compileTask.getOptions().setEncoding("UTF-8");
90-
});
78+
SpringFrameworkExtension frameworkExtension = project.getExtensions().getByType(SpringFrameworkExtension.class);
79+
project.afterEvaluate(p -> {
80+
p.getTasks().withType(JavaCompile.class)
81+
.matching(compileTask -> compileTask.getName().startsWith(JavaPlugin.COMPILE_JAVA_TASK_NAME))
82+
.forEach(compileTask -> {
83+
compileTask.getOptions().setCompilerArgs(COMPILER_ARGS);
84+
compileTask.getOptions().getCompilerArgumentProviders().add(frameworkExtension.asArgumentProvider());
85+
compileTask.getOptions().setEncoding("UTF-8");
86+
});
87+
p.getTasks().withType(JavaCompile.class)
88+
.matching(compileTask -> compileTask.getName().startsWith(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME)
89+
|| compileTask.getName().equals("compileTestFixturesJava"))
90+
.forEach(compileTask -> {
91+
compileTask.getOptions().setCompilerArgs(TEST_COMPILER_ARGS);
92+
compileTask.getOptions().getCompilerArgumentProviders().add(frameworkExtension.asArgumentProvider());
93+
compileTask.getOptions().setEncoding("UTF-8");
94+
});
95+
96+
});
9197
}
9298

9399
}
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,15 +16,14 @@
1616

1717
package org.springframework.build;
1818

19-
import java.util.ArrayList;
20-
import java.util.List;
21-
2219
import org.gradle.api.Project;
23-
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions;
20+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget;
21+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion;
2422
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
2523

2624
/**
2725
* @author Brian Clozel
26+
* @author Sebastien Deleuze
2827
*/
2928
public class KotlinConventions {
3029

@@ -34,15 +33,14 @@ void apply(Project project) {
3433
}
3534

3635
private void configure(KotlinCompile compile) {
37-
KotlinJvmOptions kotlinOptions = compile.getKotlinOptions();
38-
kotlinOptions.setApiVersion("1.7");
39-
kotlinOptions.setLanguageVersion("1.7");
40-
kotlinOptions.setJvmTarget("17");
41-
kotlinOptions.setJavaParameters(true);
42-
kotlinOptions.setAllWarningsAsErrors(true);
43-
List<String> freeCompilerArgs = new ArrayList<>(compile.getKotlinOptions().getFreeCompilerArgs());
44-
freeCompilerArgs.addAll(List.of("-Xsuppress-version-warnings", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn"));
45-
compile.getKotlinOptions().setFreeCompilerArgs(freeCompilerArgs);
36+
compile.compilerOptions(options -> {
37+
options.getApiVersion().set(KotlinVersion.KOTLIN_2_1);
38+
options.getLanguageVersion().set(KotlinVersion.KOTLIN_2_1);
39+
options.getJvmTarget().set(JvmTarget.JVM_17);
40+
options.getJavaParameters().set(true);
41+
options.getAllWarningsAsErrors().set(true);
42+
options.getFreeCompilerArgs().addAll("-Xsuppress-version-warnings", "-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn");
43+
});
4644
}
4745

4846
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2002-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.build;
18+
19+
import java.util.Collections;
20+
import java.util.List;
21+
22+
import org.gradle.api.Project;
23+
import org.gradle.api.provider.Property;
24+
import org.gradle.process.CommandLineArgumentProvider;
25+
26+
public class SpringFrameworkExtension {
27+
28+
private final Property<Boolean> enableJavaPreviewFeatures;
29+
30+
public SpringFrameworkExtension(Project project) {
31+
this.enableJavaPreviewFeatures = project.getObjects().property(Boolean.class);
32+
}
33+
34+
public Property<Boolean> getEnableJavaPreviewFeatures() {
35+
return this.enableJavaPreviewFeatures;
36+
}
37+
38+
public CommandLineArgumentProvider asArgumentProvider() {
39+
return () -> {
40+
if (getEnableJavaPreviewFeatures().getOrElse(false)) {
41+
return List.of("--enable-preview");
42+
}
43+
return Collections.emptyList();
44+
};
45+
}
46+
}

buildSrc/src/main/java/org/springframework/build/TestConventions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ private void configureTests(Project project, Test test) {
6767
"--add-opens=java.base/java.util=ALL-UNNAMED",
6868
"-Xshare:off"
6969
);
70+
test.getJvmArgumentProviders().add(project.getExtensions()
71+
.getByType(SpringFrameworkExtension.class).asArgumentProvider());
7072
}
7173

7274
private void configureTestRetryPlugin(Project project, Test test) {

framework-docs/framework-docs.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ repositories {
4141
}
4242
}
4343

44+
// To avoid a redeclaration error with Kotlin compiler
45+
sourceSets {
46+
main {
47+
java.exclude("org/springframework/docs/**/*.java")
48+
}
49+
}
50+
4451
dependencies {
4552
api(project(":spring-aspects"))
4653
api(project(":spring-context"))
@@ -68,6 +75,7 @@ dependencies {
6875
api("org.aspectj:aspectjweaver")
6976
api("org.eclipse.jetty.websocket:jetty-websocket-jetty-api")
7077
api("org.jetbrains.kotlin:kotlin-stdlib")
78+
api("jakarta.websocket:jakarta.websocket-api")
7179

7280
implementation(project(":spring-core-test"))
7381
implementation("org.assertj:assertj-core")

framework-docs/modules/ROOT/pages/core/beans/classpath-scanning.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,7 @@ By default, the `AnnotationBeanNameGenerator` is used. For Spring
674674
xref:core/beans/classpath-scanning.adoc#beans-stereotype-annotations[stereotype annotations],
675675
if you supply a name via the annotation's `value` attribute that name will be used as
676676
the name in the corresponding bean definition. This convention also applies when the
677-
following JSR-250 and JSR-330 annotations are used instead of Spring stereotype
678-
annotations: `@jakarta.annotation.ManagedBean`, `@javax.annotation.ManagedBean`,
679-
`@jakarta.inject.Named`, and `@javax.inject.Named`.
677+
`@jakarta.inject.Named` annotation is used instead of Spring stereotype annotations.
680678

681679
As of Spring Framework 6.1, the name of the annotation attribute that is used to specify
682680
the bean name is no longer required to be `value`. Custom stereotype annotations can

framework-docs/modules/ROOT/pages/integration/email.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ Spring Framework's email support:
1111
* The https://jakartaee.github.io/mail-api/[Jakarta Mail] library
1212
1313
This library is freely available on the web -- for example, in Maven Central as
14-
`com.sun.mail:jakarta.mail`. Please make sure to use the latest 2.x version (which uses
15-
the `jakarta.mail` package namespace) rather than Jakarta Mail 1.6.x (which uses the
16-
`javax.mail` package namespace).
14+
`org.eclipse.angus:angus-mail`.
1715
****
1816

1917
The Spring Framework provides a helpful utility library for sending email that shields

framework-docs/modules/ROOT/pages/languages/kotlin/requirements.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
= Requirements
33
:page-section-summary-toc: 1
44

5-
Spring Framework supports Kotlin 1.7+ and requires
5+
Spring Framework supports Kotlin 2.1+ and requires
66
https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-stdlib[`kotlin-stdlib`]
77
and https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-reflect[`kotlin-reflect`]
88
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on

framework-docs/modules/ROOT/pages/languages/kotlin/web.adoc

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -75,54 +75,6 @@ mockMvc.get("/person/{name}", "Lee") {
7575

7676

7777

78-
[[kotlin-script-templates]]
79-
== Kotlin Script Templates
80-
81-
Spring Framework provides a
82-
{spring-framework-api}/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`]
83-
which supports {JSR}223[JSR-223] to render templates by using script engines.
84-
85-
By leveraging `scripting-jsr223` dependencies, it
86-
is possible to use such feature to render Kotlin-based templates with
87-
{kotlin-github-org}/kotlinx.html[kotlinx.html] DSL or Kotlin multiline interpolated `String`.
88-
89-
`build.gradle.kts`
90-
[source,kotlin,indent=0]
91-
----
92-
dependencies {
93-
runtime("org.jetbrains.kotlin:kotlin-scripting-jsr223:${kotlinVersion}")
94-
}
95-
----
96-
97-
Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplateViewResolver` beans.
98-
99-
`KotlinScriptConfiguration.kt`
100-
[source,kotlin,indent=0]
101-
----
102-
@Configuration
103-
class KotlinScriptConfiguration {
104-
105-
@Bean
106-
fun kotlinScriptConfigurer() = ScriptTemplateConfigurer().apply {
107-
engineName = "kotlin"
108-
setScripts("scripts/render.kts")
109-
renderFunction = "render"
110-
isSharedEngine = false
111-
}
112-
113-
@Bean
114-
fun kotlinScriptViewResolver() = ScriptTemplateViewResolver().apply {
115-
setPrefix("templates/")
116-
setSuffix(".kts")
117-
}
118-
}
119-
----
120-
121-
See the https://github.com/sdeleuze/kotlin-script-templating[kotlin-script-templating] example
122-
project for more details.
123-
124-
125-
12678
[[kotlin-multiplatform-serialization]]
12779
== Kotlin multiplatform serialization
12880

framework-docs/modules/ROOT/pages/testing/annotations/integration-junit-jupiter.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ the parameters of a test class constructor are autowired from components in the
171171

172172
If `@TestConstructor` is not present or meta-present on a test class, the default _test
173173
constructor autowire mode_ will be used. See the tip below for details on how to change
174-
the default mode. Note, however, that a local declaration of `@Autowired`,
175-
`@jakarta.inject.Inject`, or `@javax.inject.Inject` on a constructor takes precedence
176-
over both `@TestConstructor` and the default mode.
174+
the default mode. Note, however, that a local declaration of `@Autowired` or
175+
`@jakarta.inject.Inject` on a constructor takes precedence over both `@TestConstructor`
176+
and the default mode.
177177

178178
.Changing the default test constructor autowire mode
179179
[TIP]

framework-docs/modules/ROOT/pages/web/webflux-view.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ Java::
466466
----
467467
@GetMapping
468468
FragmentsRendering handle() {
469-
return FragmentsRendering.with("posts").fragment("comments").build();
469+
return FragmentsRendering.fragment("posts").fragment("comments").build();
470470
}
471471
----
472472
@@ -476,7 +476,7 @@ Kotlin::
476476
----
477477
@GetMapping
478478
fun handle(): FragmentsRendering {
479-
return FragmentsRendering.with("posts").fragment("comments").build()
479+
return FragmentsRendering.fragment("posts").fragment("comments").build()
480480
}
481481
----
482482
======

framework-docs/modules/ROOT/pages/web/webflux/config.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,12 @@ For https://www.webjars.org/documentation[WebJars], versioned URLs like
647647
`/webjars/jquery/1.2.0/jquery.min.js` are the recommended and most efficient way to use them.
648648
The related resource location is configured out of the box with Spring Boot (or can be configured
649649
manually via `ResourceHandlerRegistry`) and does not require to add the
650-
`org.webjars:webjars-locator-core` dependency.
650+
`org.webjars:webjars-locator-lite` dependency.
651651

652652
Version-less URLs like `/webjars/jquery/jquery.min.js` are supported through the
653653
`WebJarsResourceResolver` which is automatically registered when the
654-
`org.webjars:webjars-locator-core` library is present on the classpath, at the cost of a
655-
classpath scanning that could slow down application startup. The resolver can re-write URLs to
656-
include the version of the jar and can also match against incoming URLs without versions
654+
`org.webjars:webjars-locator-lite` library is present on the classpath. The resolver can re-write
655+
URLs to include the version of the jar and can also match against incoming URLs without versions
657656
-- for example, from `/webjars/jquery/jquery.min.js` to `/webjars/jquery/1.2.0/jquery.min.js`.
658657

659658
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options

framework-docs/modules/ROOT/pages/web/webmvc-view/mvc-fragments.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Java::
4848
----
4949
@GetMapping
5050
FragmentsRendering handle() {
51-
return FragmentsRendering.with("posts").fragment("comments").build();
51+
return FragmentsRendering.fragment("posts").fragment("comments").build();
5252
}
5353
----
5454
@@ -58,7 +58,7 @@ Kotlin::
5858
----
5959
@GetMapping
6060
fun handle(): FragmentsRendering {
61-
return FragmentsRendering.with("posts").fragment("comments").build()
61+
return FragmentsRendering.fragment("posts").fragment("comments").build()
6262
}
6363
----
6464
======

framework-docs/modules/ROOT/pages/web/webmvc/filters.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ available through the `ServletRequest.getParameter{asterisk}()` family of method
3030

3131

3232

33-
[[forwarded-headers]]
33+
[[filters-forwarded-headers]]
3434
== Forwarded Headers
3535
[.small]#xref:web/webflux/reactive-spring.adoc#webflux-forwarded-headers[See equivalent in the Reactive stack]#
3636

framework-docs/modules/ROOT/pages/web/webmvc/mvc-config/static-resources.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ For https://www.webjars.org/documentation[WebJars], versioned URLs like
4848
`/webjars/jquery/1.2.0/jquery.min.js` are the recommended and most efficient way to use them.
4949
The related resource location is configured out of the box with Spring Boot (or can be configured
5050
manually via `ResourceHandlerRegistry`) and does not require to add the
51-
`org.webjars:webjars-locator-core` dependency.
51+
`org.webjars:webjars-locator-lite` dependency.
5252

5353
Version-less URLs like `/webjars/jquery/jquery.min.js` are supported through the
5454
`WebJarsResourceResolver` which is automatically registered when the
55-
`org.webjars:webjars-locator-core` library is present on the classpath, at the cost of a
56-
classpath scanning that could slow down application startup. The resolver can re-write URLs to
57-
include the version of the jar and can also match against incoming URLs without versions
55+
`org.webjars:webjars-locator-lite` library is present on the classpath. The resolver can re-write
56+
URLs to include the version of the jar and can also match against incoming URLs without versions
5857
-- for example, from `/webjars/jquery/jquery.min.js` to `/webjars/jquery/1.2.0/jquery.min.js`.
5958

6059
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options

0 commit comments

Comments
 (0)