parent
b52a781f7b
commit
bebca55a8f
|
@ -1115,7 +1115,7 @@ This is especially useful for Testcontainer `Container` beans, as they keep thei
|
|||
|
||||
include::code:MyContainersConfiguration[]
|
||||
|
||||
WARNING: If you're using Gradle and want to use this feature, you need to change the configuration of the `spring-boot-devtools` dependency from `developmentOnly` to `testImplementation`.
|
||||
WARNING: If you're using Gradle and want to use this feature, you need to change the configuration of the `spring-boot-devtools` dependency from `developmentOnly` to `testAndDevelopmentOnly`.
|
||||
With the default scope of `developmentOnly`, the `bootTestRun` task will not pick up changes in your code, as the devtools are not active.
|
||||
|
||||
|
||||
|
|
|
@ -18,9 +18,10 @@ When Gradle's {java-plugin}[`java` plugin] is applied to a project, the Spring B
|
|||
6. Creates a {boot-run-javadoc}['BootRun`] task named `bootTestRun` that can be used to run your application using the `test` source set to find its main method and provide its runtime classpath.
|
||||
7. Creates a configuration named `bootArchives` that contains the artifact produced by the `bootJar` task.
|
||||
8. Creates a configuration named `developmentOnly` for dependencies that are only required at development time, such as Spring Boot's Devtools, and should not be packaged in executable jars and wars.
|
||||
9. Creates a configuration named `productionRuntimeClasspath`. It is equivalent to `runtimeClasspath` minus any dependencies that only appear in the `developmentOnly` configuration.
|
||||
10. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
|
||||
11. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
|
||||
9. Creats a configuration named `testAndDevelopmentOnly` for dependencies that are only required at development time and when writing and running tests and that should not be packaged in executable jars and wars.
|
||||
10. Creates a configuration named `productionRuntimeClasspath`. It is equivalent to `runtimeClasspath` minus any dependencies that only appear in the `developmentOnly` or `testDevelopmentOnly` configurations.
|
||||
11. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
|
||||
12. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,9 @@ final class JavaPluginAction implements PluginApplicationAction {
|
|||
public void execute(Project project) {
|
||||
classifyJarTask(project);
|
||||
configureBuildTask(project);
|
||||
configureProductionRuntimeClasspathConfiguration(project);
|
||||
configureDevelopmentOnlyConfiguration(project);
|
||||
configureTestAndDevelopmentOnlyConfiguration(project);
|
||||
TaskProvider<ResolveMainClassName> resolveMainClassName = configureResolveMainClassNameTask(project);
|
||||
TaskProvider<BootJar> bootJar = configureBootJarTask(project, resolveMainClassName);
|
||||
configureBootBuildImageTask(project, bootJar);
|
||||
|
@ -160,12 +162,15 @@ final class JavaPluginAction implements PluginApplicationAction {
|
|||
.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
|
||||
Configuration developmentOnly = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
Configuration testAndDevelopmentOnly = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
Configuration productionRuntimeClasspath = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
Configuration runtimeClasspath = project.getConfigurations()
|
||||
.getByName(mainSourceSet.getRuntimeClasspathConfigurationName());
|
||||
Callable<FileCollection> classpath = () -> mainSourceSet.getRuntimeClasspath()
|
||||
.minus((developmentOnly.minus(productionRuntimeClasspath)))
|
||||
.minus((testAndDevelopmentOnly.minus(productionRuntimeClasspath)))
|
||||
.filter(new JarTypeFileSpec());
|
||||
return project.getTasks().register(SpringBootPlugin.BOOT_JAR_TASK_NAME, BootJar.class, (bootJar) -> {
|
||||
bootJar.setDescription(
|
||||
|
@ -270,13 +275,7 @@ final class JavaPluginAction implements PluginApplicationAction {
|
|||
.ifPresent((locations) -> compile.doFirst(new AdditionalMetadataLocationsConfigurer(locations)));
|
||||
}
|
||||
|
||||
private void configureDevelopmentOnlyConfiguration(Project project) {
|
||||
Configuration developmentOnly = project.getConfigurations()
|
||||
.create(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
developmentOnly
|
||||
.setDescription("Configuration for development-only dependencies such as Spring Boot's DevTools.");
|
||||
Configuration runtimeClasspath = project.getConfigurations()
|
||||
.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
private void configureProductionRuntimeClasspathConfiguration(Project project) {
|
||||
Configuration productionRuntimeClasspath = project.getConfigurations()
|
||||
.create(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
AttributeContainer attributes = productionRuntimeClasspath.getAttributes();
|
||||
|
@ -286,12 +285,37 @@ final class JavaPluginAction implements PluginApplicationAction {
|
|||
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
|
||||
objectFactory.named(LibraryElements.class, LibraryElements.JAR));
|
||||
productionRuntimeClasspath.setVisible(false);
|
||||
Configuration runtimeClasspath = project.getConfigurations()
|
||||
.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom());
|
||||
productionRuntimeClasspath.setCanBeResolved(runtimeClasspath.isCanBeResolved());
|
||||
productionRuntimeClasspath.setCanBeConsumed(runtimeClasspath.isCanBeConsumed());
|
||||
}
|
||||
|
||||
private void configureDevelopmentOnlyConfiguration(Project project) {
|
||||
Configuration developmentOnly = project.getConfigurations()
|
||||
.create(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
developmentOnly
|
||||
.setDescription("Configuration for development-only dependencies such as Spring Boot's DevTools.");
|
||||
Configuration runtimeClasspath = project.getConfigurations()
|
||||
.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
|
||||
runtimeClasspath.extendsFrom(developmentOnly);
|
||||
}
|
||||
|
||||
private void configureTestAndDevelopmentOnlyConfiguration(Project project) {
|
||||
Configuration testAndDevelopmentOnly = project.getConfigurations()
|
||||
.create(SpringBootPlugin.TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
testAndDevelopmentOnly
|
||||
.setDescription("Configuration for test and development-only dependencies such as Spring Boot's DevTools.");
|
||||
Configuration runtimeClasspath = project.getConfigurations()
|
||||
.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
runtimeClasspath.extendsFrom(testAndDevelopmentOnly);
|
||||
Configuration testImplementation = project.getConfigurations()
|
||||
.getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME);
|
||||
testImplementation.extendsFrom(testAndDevelopmentOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* Task {@link Action} to add additional meta-data locations. We need to use an
|
||||
* inner-class rather than a lambda due to
|
||||
|
|
|
@ -83,7 +83,8 @@ class NativeImagePluginAction implements PluginApplicationAction {
|
|||
}
|
||||
|
||||
private boolean isNotDevelopmentOnly(Configuration configuration) {
|
||||
return !SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME.equals(configuration.getName());
|
||||
return !SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME.equals(configuration.getName())
|
||||
&& !SpringBootPlugin.TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME.equals(configuration.getName());
|
||||
}
|
||||
|
||||
private void configureTestNativeBinaryClasspath(SourceSetContainer sourceSets, GraalVMExtension graalVmExtension) {
|
||||
|
|
|
@ -117,7 +117,9 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
private void registerProcessAotTask(Project project, SourceSet aotSourceSet, SourceSet mainSourceSet) {
|
||||
TaskProvider<ResolveMainClassName> resolveMainClassName = project.getTasks()
|
||||
.named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class);
|
||||
Configuration aotClasspath = createAotProcessingClasspath(project, PROCESS_AOT_TASK_NAME, mainSourceSet);
|
||||
Configuration aotClasspath = createAotProcessingClasspath(project, PROCESS_AOT_TASK_NAME, mainSourceSet,
|
||||
Set.of(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME,
|
||||
SpringBootPlugin.TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME));
|
||||
project.getDependencies().add(aotClasspath.getName(), project.files(mainSourceSet.getOutput()));
|
||||
Configuration compileClasspath = project.getConfigurations()
|
||||
.getByName(aotSourceSet.getCompileClasspathConfigurationName());
|
||||
|
@ -152,14 +154,16 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet) {
|
||||
private Configuration createAotProcessingClasspath(Project project, String taskName, SourceSet inputSourceSet,
|
||||
Set<String> developmentOnlyConfigurationNames) {
|
||||
Configuration base = project.getConfigurations()
|
||||
.getByName(inputSourceSet.getRuntimeClasspathConfigurationName());
|
||||
return project.getConfigurations().create(taskName + "Classpath", (classpath) -> {
|
||||
classpath.setCanBeConsumed(false);
|
||||
classpath.setCanBeResolved(true);
|
||||
classpath.setDescription("Classpath of the " + taskName + " task.");
|
||||
removeDevelopmentOnly(base.getExtendsFrom()).forEach(classpath::extendsFrom);
|
||||
removeDevelopmentOnly(base.getExtendsFrom(), developmentOnlyConfigurationNames)
|
||||
.forEach(classpath::extendsFrom);
|
||||
classpath.attributes((attributes) -> {
|
||||
ProviderFactory providers = project.getProviders();
|
||||
AttributeContainer baseAttributes = base.getAttributes();
|
||||
|
@ -171,12 +175,10 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
});
|
||||
}
|
||||
|
||||
private Stream<Configuration> removeDevelopmentOnly(Set<Configuration> configurations) {
|
||||
return configurations.stream().filter(this::isNotDevelopmentOnly);
|
||||
}
|
||||
|
||||
private boolean isNotDevelopmentOnly(Configuration configuration) {
|
||||
return !SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME.equals(configuration.getName());
|
||||
private Stream<Configuration> removeDevelopmentOnly(Set<Configuration> configurations,
|
||||
Set<String> developmentOnlyConfigurationNames) {
|
||||
return configurations.stream()
|
||||
.filter((configuration) -> !developmentOnlyConfigurationNames.contains(configuration.getName()));
|
||||
}
|
||||
|
||||
private void configureDependsOn(Project project, SourceSet aotSourceSet,
|
||||
|
@ -188,7 +190,8 @@ public class SpringBootAotPlugin implements Plugin<Project> {
|
|||
|
||||
private void registerProcessTestAotTask(Project project, SourceSet mainSourceSet, SourceSet aotTestSourceSet,
|
||||
SourceSet testSourceSet) {
|
||||
Configuration aotClasspath = createAotProcessingClasspath(project, PROCESS_TEST_AOT_TASK_NAME, testSourceSet);
|
||||
Configuration aotClasspath = createAotProcessingClasspath(project, PROCESS_TEST_AOT_TASK_NAME, testSourceSet,
|
||||
Set.of(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME));
|
||||
addJUnitPlatformLauncherDependency(project, aotClasspath);
|
||||
Configuration compileClasspath = project.getConfigurations()
|
||||
.getByName(aotTestSourceSet.getCompileClasspathConfigurationName());
|
||||
|
|
|
@ -80,6 +80,12 @@ public class SpringBootPlugin implements Plugin<Project> {
|
|||
*/
|
||||
public static final String DEVELOPMENT_ONLY_CONFIGURATION_NAME = "developmentOnly";
|
||||
|
||||
/**
|
||||
* The name of the {@code testAndDevelopmentOnly} configuration.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static final String TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME = "testAndDevelopmentOnly";
|
||||
|
||||
/**
|
||||
* The name of the {@code productionRuntimeClasspath} configuration.
|
||||
*/
|
||||
|
|
|
@ -72,6 +72,8 @@ class WarPluginAction implements PluginApplicationAction {
|
|||
private TaskProvider<BootWar> configureBootWarTask(Project project) {
|
||||
Configuration developmentOnly = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
Configuration testAndDevelopmentOnly = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.TEST_AND_DEVELOPMENT_ONLY_CONFIGURATION_NAME);
|
||||
Configuration productionRuntimeClasspath = project.getConfigurations()
|
||||
.getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
|
||||
SourceSet mainSourceSet = project.getExtensions()
|
||||
|
@ -82,6 +84,7 @@ class WarPluginAction implements PluginApplicationAction {
|
|||
Callable<FileCollection> classpath = () -> mainSourceSet.getRuntimeClasspath()
|
||||
.minus(providedRuntimeConfiguration(project))
|
||||
.minus((developmentOnly.minus(productionRuntimeClasspath)))
|
||||
.minus((testAndDevelopmentOnly.minus(productionRuntimeClasspath)))
|
||||
.filter(new JarTypeFileSpec());
|
||||
TaskProvider<ResolveMainClassName> resolveMainClassName = project.getTasks()
|
||||
.named(SpringBootPlugin.RESOLVE_MAIN_CLASS_NAME_TASK_NAME, ResolveMainClassName.class);
|
||||
|
|
|
@ -142,7 +142,52 @@ class JavaPluginActionIntegrationTests {
|
|||
|
||||
@TestTemplate
|
||||
void applyingJavaPluginCreatesDevelopmentOnlyConfiguration() {
|
||||
assertThat(this.gradleBuild.build("build").getOutput()).contains("developmentOnly exists = true");
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("developmentOnly exists = true");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void applyingJavaPluginCreatesTestAndDevelopmentOnlyConfiguration() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("testAndDevelopmentOnly exists = true");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testCompileClasspathIncludesTestAndDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testRuntimeClasspathIncludesTestAndDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testCompileClasspathDoesNotIncludeDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testRuntimeClasspathDoesNotIncludeDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void compileClasspathDoesNotIncludeTestAndDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void runtimeClasspathIncludesTestAndDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void compileClasspathDoesNotIncludeDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void runtimeClasspathIncludesDevelopmentOnlyDependencies() {
|
||||
assertThat(this.gradleBuild.build("help").getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
|
|
|
@ -105,6 +105,14 @@ class NativeImagePluginActionIntegrationTests {
|
|||
assertThat(result.getOutput()).doesNotContain("commons-lang");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesDoNotAppearInNativeImageClasspath() {
|
||||
writeDummySpringApplicationAotProcessorMainClass();
|
||||
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
|
||||
.build("checkNativeImageClasspath");
|
||||
assertThat(result.getOutput()).doesNotContain("commons-lang");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void classesGeneratedDuringAotProcessingAreOnTheNativeImageClasspath() {
|
||||
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
|
||||
|
|
|
@ -106,10 +106,22 @@ class SpringBootAotPluginIntegrationTests {
|
|||
|
||||
@TestTemplate
|
||||
void processTestAotDoesNotHaveDevelopmentOnlyDependenciesOnItsClasspath() {
|
||||
String output = this.gradleBuild.build("processTestAotClasspath", "--stacktrace").getOutput();
|
||||
String output = this.gradleBuild.build("processTestAotClasspath").getOutput();
|
||||
assertThat(output).doesNotContain("commons-lang");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processAotDoesNotHaveTestAndDevelopmentOnlyDependenciesOnItsClasspath() {
|
||||
String output = this.gradleBuild.build("processAotClasspath").getOutput();
|
||||
assertThat(output).doesNotContain("commons-lang");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processTestAotHasTestAndDevelopmentOnlyDependenciesOnItsClasspath() {
|
||||
String output = this.gradleBuild.build("processTestAotClasspath").getOutput();
|
||||
assertThat(output).contains("commons-lang");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void processAotRunsWhenProjectHasMainSource() throws IOException {
|
||||
writeMainClass("org.springframework.boot", "SpringApplicationAotProcessor");
|
||||
|
|
|
@ -221,6 +221,41 @@ abstract class AbstractBootArchiveIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesAreNotIncludedInTheArchiveByDefault() throws IOException {
|
||||
File srcMainResources = new File(this.gradleBuild.getProjectDir(), "src/main/resources");
|
||||
srcMainResources.mkdirs();
|
||||
new File(srcMainResources, "resource").createNewFile();
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
.map(JarEntry::getName)
|
||||
.filter((name) -> name.startsWith(this.libPath));
|
||||
assertThat(libEntryNames).containsExactly(this.libPath + "commons-io-2.6.jar");
|
||||
Stream<String> classesEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
.map(JarEntry::getName)
|
||||
.filter((name) -> name.startsWith(this.classesPath));
|
||||
assertThat(classesEntryNames).containsExactly(this.classesPath + "resource");
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesCanBeIncludedInTheArchive() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
Stream<String> libEntryNames = jarFile.stream()
|
||||
.filter((entry) -> !entry.isDirectory())
|
||||
.map(JarEntry::getName)
|
||||
.filter((name) -> name.startsWith(this.libPath));
|
||||
assertThat(libEntryNames).containsExactly(this.libPath + "commons-io-2.6.jar",
|
||||
this.libPath + "commons-lang3-3.9.jar");
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void jarTypeFilteringIsApplied() throws IOException {
|
||||
File flatDirRepository = new File(this.gradleBuild.getProjectDir(), "repository");
|
||||
|
|
|
@ -146,6 +146,22 @@ class BootRunIntegrationTests {
|
|||
assertThat(result.getOutput()).contains("com.example.bootrun.main.CustomMainClass");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void developmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
private void copyMainClassApplication() throws IOException {
|
||||
copyApplication("main");
|
||||
}
|
||||
|
|
|
@ -117,6 +117,22 @@ class BootTestRunIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void developmentOnlyDependenciesAreNotOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).doesNotContain("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void testAndDevelopmentOnlyDependenciesAreOnTheClasspath() throws IOException {
|
||||
copyClasspathApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootTestRun");
|
||||
assertThat(result.task(":bootTestRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("commons-lang3-3.12.0.jar");
|
||||
}
|
||||
|
||||
private void copyClasspathApplication() throws IOException {
|
||||
copyApplication("classpath");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
println "testAndDevelopmentOnly exists = ${configurations.findByName('testAndDevelopmentOnly') != null}"
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.compileClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.compileClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.runtimeClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.runtimeClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.testCompileClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.testCompileClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.testRuntimeClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
configurations.testRuntimeClasspath.resolve().each { println it }
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'org.graalvm.buildtools.native'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
task('checkNativeImageClasspath') {
|
||||
doFirst {
|
||||
tasks.nativeCompile.options.get().classpath.each { println it }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot.aot'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
task('processAotClasspath') {
|
||||
doFirst {
|
||||
tasks.processAot.classpath.each { println it }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot.aot'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'file:repository' }
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
eachDependency {
|
||||
if (it.requested.group == 'org.springframework.boot') {
|
||||
it.useVersion project.bootVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
||||
|
||||
task('processTestAotClasspath') {
|
||||
doFirst {
|
||||
tasks.processTestAot.classpath.each { println it }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.9")
|
||||
testAndDevelopmentOnly("commons-io:commons-io:2.6")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
}
|
||||
|
||||
bootJar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
}
|
||||
|
||||
bootJar {
|
||||
classpath configurations.testAndDevelopmentOnly
|
||||
}
|
||||
|
||||
bootJar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.9")
|
||||
testAndDevelopmentOnly("commons-io:commons-io:2.6")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
}
|
||||
|
||||
bootWar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
plugins {
|
||||
id 'war'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
bootWar {
|
||||
mainClass = 'com.example.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.9")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
}
|
||||
|
||||
bootWar {
|
||||
classpath configurations.testAndDevelopmentOnly
|
||||
}
|
||||
|
||||
bootWar {
|
||||
layered {
|
||||
enabled = false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
developmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testAndDevelopmentOnly("org.apache.commons:commons-lang3:3.12.0")
|
||||
}
|
Loading…
Reference in New Issue