diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java index cef1a8e315..e1981da021 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 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. @@ -89,6 +89,7 @@ final class JavaPluginAction implements PluginApplicationAction { project.afterEvaluate(this::configureUtf8Encoding); configureParametersCompilerArg(project); configureAdditionalMetadataLocations(project); + configureSpringBootStarterTestToDependOnJUnitPlatformLauncher(project); } private void classifyJarTask(Project project) { @@ -317,6 +318,15 @@ final class JavaPluginAction implements PluginApplicationAction { testImplementation.extendsFrom(testAndDevelopmentOnly); } + private void configureSpringBootStarterTestToDependOnJUnitPlatformLauncher(Project project) { + project.getDependencies() + .components((components) -> components.withModule("org.springframework.boot:spring-boot-starter-test", + (metadata) -> metadata.withVariant("runtimeElements", (variant) -> variant.withDependencies( + (dependencies) -> dependencies.add("org.junit.platform:junit-platform-launcher") + + )))); + } + /** * Task {@link Action} to add additional meta-data locations. We need to use an * inner-class rather than a lambda due to