Merge branch '3.2.x' into 3.3.x

Closes gh-41257
This commit is contained in:
Andy Wilkinson 2024-06-27 10:16:36 +01:00
commit b0d4f1d356
416 changed files with 730 additions and 440 deletions

View File

@ -105,6 +105,10 @@ gradlePlugin {
id = "org.springframework.boot.deployed"
implementationClass = "org.springframework.boot.build.DeployedPlugin"
}
dockerTestPlugin {
id = "org.springframework.boot.docker-test"
implementationClass = "org.springframework.boot.build.test.DockerTestPlugin"
}
integrationTestPlugin {
id = "org.springframework.boot.integration-test"
implementationClass = "org.springframework.boot.build.test.IntegrationTestPlugin"

View File

@ -87,6 +87,7 @@ import org.xml.sax.SAXException;
import org.springframework.boot.build.DeployedPlugin;
import org.springframework.boot.build.MavenRepositoryPlugin;
import org.springframework.boot.build.test.DockerTestPlugin;
import org.springframework.boot.build.test.IntegrationTestPlugin;
import org.springframework.core.CollectionFactory;
import org.springframework.util.Assert;
@ -138,11 +139,15 @@ public class MavenPluginPlugin implements Plugin<Project> {
.set(new File(project.getBuildDir(), "runtime-classpath-repository"));
project.getDependencies()
.components((components) -> components.all(MavenRepositoryComponentMetadataRule.class));
Sync task = project.getTasks().create("populateIntTestMavenRepository", Sync.class);
task.setDestinationDir(new File(project.getBuildDir(), "int-test-maven-repository"));
Sync task = project.getTasks().create("populateTestMavenRepository", Sync.class);
task.setDestinationDir(new File(project.getBuildDir(), "test-maven-repository"));
task.with(copyIntTestMavenRepositoryFiles(project, runtimeClasspathMavenRepository));
task.dependsOn(project.getTasks().getByName(MavenRepositoryPlugin.PUBLISH_TO_PROJECT_REPOSITORY_TASK_NAME));
project.getTasks().getByName(IntegrationTestPlugin.INT_TEST_TASK_NAME).dependsOn(task);
project.getPlugins()
.withType(DockerTestPlugin.class)
.all((dockerTestPlugin) -> project.getTasks()
.named(DockerTestPlugin.DOCKER_TEST_TASK_NAME, (dockerTest) -> dockerTest.dependsOn(task)));
}
private CopySpec copyIntTestMavenRepositoryFiles(Project project,

View File

@ -0,0 +1,38 @@
/*
* Copyright 2012-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
*
* 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 org.springframework.boot.build.test;
import org.gradle.api.Project;
import org.gradle.api.provider.Provider;
import org.gradle.api.services.BuildService;
import org.gradle.api.services.BuildServiceParameters;
/**
* Build service for Docker-based tests. Configured to only allow serial execution,
* thereby ensuring that Docker-based tests do not run in parallel.
*
* @author Andy Wilkinson
*/
abstract class DockerTestBuildService implements BuildService<BuildServiceParameters.None> {
static Provider<DockerTestBuildService> registerIfNecessary(Project project) {
return project.getGradle()
.getSharedServices()
.registerIfAbsent("dockerTest", DockerTestBuildService.class, (spec) -> spec.getMaxParallelUsages().set(1));
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright 2012-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
*
* 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 org.springframework.boot.build.test;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginExtension;
import org.gradle.api.provider.Provider;
import org.gradle.api.services.BuildService;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.SourceSetContainer;
import org.gradle.api.tasks.testing.Test;
import org.gradle.language.base.plugins.LifecycleBasePlugin;
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
/**
* Plugin for Docker-based tests. Creates a {@link SourceSet source set}, {@link Test
* test} task, and {@link BuildService shared service} named {@code dockerTest}. The build
* service is configured to only allow serial usage and the {@code dockerTest} task is
* configured to use the build service. In a parallel build, this ensures that only a
* single {@code dockerTest} task can run at any given time.
*
* @author Andy Wilkinson
*/
public class DockerTestPlugin implements Plugin<Project> {
/**
* Name of the {@code dockerTest} task.
*/
public static String DOCKER_TEST_TASK_NAME = "dockerTest";
/**
* Name of the {@code dockerTest} source set.
*/
public static String DOCKER_TEST_SOURCE_SET_NAME = "dockerTest";
/**
* Name of the {@code dockerTest} shared service.
*/
public static String DOCKER_TEST_SERVICE_NAME = "dockerTest";
@Override
public void apply(Project project) {
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> configureDockerTesting(project));
}
private void configureDockerTesting(Project project) {
Provider<DockerTestBuildService> buildService = DockerTestBuildService.registerIfNecessary(project);
SourceSet dockerTestSourceSet = createSourceSet(project);
Provider<Test> dockerTest = createTestTask(project, dockerTestSourceSet, buildService);
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(dockerTest);
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
eclipse.classpath((classpath) -> classpath.getPlusConfigurations()
.add(project.getConfigurations()
.getByName(dockerTestSourceSet.getRuntimeClasspathConfigurationName())));
});
}
private SourceSet createSourceSet(Project project) {
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
SourceSet dockerTestSourceSet = sourceSets.create(DOCKER_TEST_SOURCE_SET_NAME);
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
dockerTestSourceSet.setCompileClasspath(dockerTestSourceSet.getCompileClasspath()
.plus(main.getOutput())
.plus(main.getCompileClasspath())
.plus(test.getOutput()));
dockerTestSourceSet.setRuntimeClasspath(dockerTestSourceSet.getRuntimeClasspath()
.plus(main.getOutput())
.plus(main.getRuntimeClasspath())
.plus(test.getOutput()));
project.getPlugins().withType(IntegrationTestPlugin.class, (integrationTestPlugin) -> {
SourceSet intTest = sourceSets.getByName(IntegrationTestPlugin.INT_TEST_SOURCE_SET_NAME);
dockerTestSourceSet
.setCompileClasspath(dockerTestSourceSet.getCompileClasspath().plus(intTest.getOutput()));
dockerTestSourceSet
.setRuntimeClasspath(dockerTestSourceSet.getRuntimeClasspath().plus(intTest.getOutput()));
});
return dockerTestSourceSet;
}
private Provider<Test> createTestTask(Project project, SourceSet dockerTestSourceSet,
Provider<DockerTestBuildService> buildService) {
Provider<Test> dockerTest = project.getTasks().register(DOCKER_TEST_TASK_NAME, Test.class, (task) -> {
task.usesService(buildService);
task.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
task.setDescription("Runs Docker-based tests.");
task.setTestClassesDirs(dockerTestSourceSet.getOutput().getClassesDirs());
task.setClasspath(dockerTestSourceSet.getRuntimeClasspath());
task.shouldRunAfter(JavaPlugin.TEST_TASK_NAME);
});
return dockerTest;
}
}

View File

@ -64,6 +64,7 @@ include "spring-boot-project:spring-boot-tools:spring-boot-loader-tools"
include "spring-boot-project:spring-boot-tools:spring-boot-maven-plugin"
include "spring-boot-project:spring-boot-tools:spring-boot-properties-migrator"
include "spring-boot-project:spring-boot-tools:spring-boot-test-support"
include "spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"
include "spring-boot-project:spring-boot"
include "spring-boot-project:spring-boot-autoconfigure"
include "spring-boot-project:spring-boot-actuator"

View File

@ -3,6 +3,7 @@ plugins {
id "org.springframework.boot.conventions"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.optional-dependencies"
id "org.springframework.boot.docker-test"
id "org.springframework.boot.deployed"
}
@ -10,6 +11,17 @@ description = "Spring Boot Actuator"
dependencies {
api(project(":spring-boot-project:spring-boot"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-test"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
dockerTestImplementation("org.assertj:assertj-core")
dockerTestImplementation("org.junit.jupiter:junit-jupiter")
dockerTestImplementation("org.springframework:spring-test")
dockerTestImplementation("org.testcontainers:junit-jupiter")
dockerTestImplementation("org.testcontainers:mongodb")
dockerTestImplementation("org.testcontainers:neo4j")
dockerTestImplementation("org.testcontainers:testcontainers")
optional("org.apache.cassandra:java-driver-core") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"
@ -100,10 +112,6 @@ dependencies {
testImplementation("org.skyscreamer:jsonassert")
testImplementation("org.springframework:spring-test")
testImplementation("com.squareup.okhttp3:mockwebserver")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:mongodb")
testImplementation("org.testcontainers:neo4j")
testImplementation("org.testcontainers:testcontainers")
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("io.projectreactor.netty:reactor-netty-http")

View File

@ -4,6 +4,7 @@ plugins {
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.conventions"
id "org.springframework.boot.deployed"
id "org.springframework.boot.docker-test"
id "org.springframework.boot.optional-dependencies"
}
@ -12,6 +13,21 @@ description = "Spring Boot AutoConfigure"
dependencies {
api(project(":spring-boot-project:spring-boot"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-test"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
dockerTestImplementation("org.assertj:assertj-core")
dockerTestImplementation("org.junit.jupiter:junit-jupiter")
dockerTestImplementation("org.mockito:mockito-core")
dockerTestImplementation("org.springframework:spring-test")
dockerTestImplementation("org.testcontainers:cassandra")
dockerTestImplementation("org.testcontainers:couchbase")
dockerTestImplementation("org.testcontainers:elasticsearch")
dockerTestImplementation("org.testcontainers:junit-jupiter")
dockerTestImplementation("org.testcontainers:mongodb")
dockerTestImplementation("org.testcontainers:neo4j")
dockerTestImplementation("org.testcontainers:pulsar")
dockerTestImplementation("org.testcontainers:testcontainers")
optional("co.elastic.clients:elasticsearch-java") {
exclude group: "commons-logging", module: "commons-logging"
}
@ -239,14 +255,6 @@ dependencies {
}
testImplementation("org.springframework.pulsar:spring-pulsar-cache-provider-caffeine")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.testcontainers:cassandra")
testImplementation("org.testcontainers:couchbase")
testImplementation("org.testcontainers:elasticsearch")
testImplementation("org.testcontainers:junit-jupiter")
testImplementation("org.testcontainers:mongodb")
testImplementation("org.testcontainers:neo4j")
testImplementation("org.testcontainers:pulsar")
testImplementation("org.testcontainers:testcontainers")
testImplementation("org.yaml:snakeyaml")
testRuntimeOnly("jakarta.management.j2ee:jakarta.management.j2ee-api")

View File

@ -1,9 +1,10 @@
plugins {
id "java-library"
id "java-library"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.conventions"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
id "org.springframework.boot.docker-test"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot Docker Compose Support"
@ -11,6 +12,16 @@ description = "Spring Boot Docker Compose Support"
dependencies {
api(project(":spring-boot-project:spring-boot"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
dockerTestImplementation("org.assertj:assertj-core")
dockerTestImplementation("org.awaitility:awaitility")
dockerTestImplementation("org.junit.jupiter:junit-jupiter")
dockerTestImplementation("org.testcontainers:testcontainers")
dockerTestRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc")
dockerTestRuntimeOnly("com.oracle.database.r2dbc:oracle-r2dbc")
dockerTestRuntimeOnly("io.r2dbc:r2dbc-mssql")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names")
@ -25,14 +36,8 @@ dependencies {
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation("ch.qos.logback:logback-classic")
testImplementation("org.assertj:assertj-core")
testImplementation("org.awaitility:awaitility")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.mockito:mockito-core")
testImplementation("org.springframework:spring-core-test")
testImplementation("org.springframework:spring-test")
testImplementation("org.testcontainers:testcontainers")
testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc")
testRuntimeOnly("com.oracle.database.r2dbc:oracle-r2dbc")
testRuntimeOnly("io.r2dbc:r2dbc-mssql")
}

View File

@ -23,7 +23,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MariaDbJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MariaDbJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Scott Frederick
*/

View File

@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MariaDbR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MariaDbR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Scott Frederick
*/

View File

@ -23,7 +23,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MariaDbJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MariaDbJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Moritz Halbritter
* @author Andy Wilkinson

View File

@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MariaDbR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MariaDbR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Moritz Halbritter
* @author Andy Wilkinson

View File

@ -23,7 +23,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MySqlJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MySqlJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Scott Frederick
*/

View File

@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MySqlR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MySqlR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Scott Frederick
*/

View File

@ -23,7 +23,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MySqlJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MySqlJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Moritz Halbritter
* @author Andy Wilkinson

View File

@ -25,7 +25,7 @@ import org.springframework.boot.testsupport.container.TestImage;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link MySqlR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link MySqlR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Moritz Halbritter
* @author Andy Wilkinson

View File

@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link OracleFreeJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link OracleFreeJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

View File

@ -33,7 +33,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link OracleFreeR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link OracleFreeR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

View File

@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link OracleXeJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link OracleXeJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

View File

@ -33,7 +33,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link OracleXeR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link OracleXeR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

View File

@ -32,7 +32,7 @@ import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link SqlServerJdbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link SqlServerJdbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

View File

@ -32,7 +32,7 @@ import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link SqlServerR2dbcDockerComposeConnectionDetailsFactory}
* Integration tests for {@link SqlServerR2dbcDockerComposeConnectionDetailsFactory}.
*
* @author Andy Wilkinson
*/

Some files were not shown because too many files have changed in this diff Show More