Merge branch '2.7.x' into 3.0.x

Closes gh-35707
pull/35611/head
Andy Wilkinson 1 year ago
commit 5a793a6d49

@ -36,6 +36,8 @@ import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator; import org.gradle.jvm.application.scripts.TemplateBasedScriptGenerator;
import org.gradle.jvm.application.tasks.CreateStartScripts; import org.gradle.jvm.application.tasks.CreateStartScripts;
import org.springframework.boot.gradle.tasks.run.BootRun;
/** /**
* Action that is executed in response to the {@link ApplicationPlugin} being applied. * Action that is executed in response to the {@link ApplicationPlugin} being applied.
* *
@ -56,6 +58,10 @@ final class ApplicationPluginAction implements PluginApplicationAction {
CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts); CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts);
binCopySpec.setFileMode(0755); binCopySpec.setFileMode(0755);
distribution.getContents().with(binCopySpec); distribution.getContents().with(binCopySpec);
project.getTasks()
.named(SpringBootPlugin.BOOT_RUN_TASK_NAME, BootRun.class)
.configure((bootRun) -> bootRun.getConventionMapping()
.map("jvmArgs", javaApplication::getApplicationDefaultJvmArgs));
} }
private void configureCreateStartScripts(Project project, JavaApplication javaApplication, private void configureCreateStartScripts(Project project, JavaApplication javaApplication,

@ -17,7 +17,6 @@
package org.springframework.boot.gradle.plugin; package org.springframework.boot.gradle.plugin;
import java.io.File; import java.io.File;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -182,16 +181,10 @@ final class JavaPluginAction implements PluginApplicationAction {
.findByName(SourceSet.MAIN_SOURCE_SET_NAME) .findByName(SourceSet.MAIN_SOURCE_SET_NAME)
.getRuntimeClasspath() .getRuntimeClasspath()
.filter(new JarTypeFileSpec()); .filter(new JarTypeFileSpec());
project.getTasks().register("bootRun", BootRun.class, (run) -> { project.getTasks().register(SpringBootPlugin.BOOT_RUN_TASK_NAME, BootRun.class, (run) -> {
run.setDescription("Runs this project as a Spring Boot application."); run.setDescription("Runs this project as a Spring Boot application.");
run.setGroup(ApplicationPlugin.APPLICATION_GROUP); run.setGroup(ApplicationPlugin.APPLICATION_GROUP);
run.classpath(classpath); run.classpath(classpath);
run.getConventionMapping().map("jvmArgs", () -> {
if (project.hasProperty("applicationDefaultJvmArgs")) {
return project.property("applicationDefaultJvmArgs");
}
return Collections.emptyList();
});
run.getMainClass().convention(resolveMainClassName.flatMap(ResolveMainClassName::readMainClassName)); run.getMainClass().convention(resolveMainClassName.flatMap(ResolveMainClassName::readMainClassName));
configureToolchainConvention(project, run); configureToolchainConvention(project, run);
}); });

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,6 +70,8 @@ public class SpringBootPlugin implements Plugin<Project> {
*/ */
public static final String BOOT_BUILD_IMAGE_TASK_NAME = "bootBuildImage"; public static final String BOOT_BUILD_IMAGE_TASK_NAME = "bootBuildImage";
static final String BOOT_RUN_TASK_NAME = "bootRun";
/** /**
* The name of the {@code developmentOnly} configuration. * The name of the {@code developmentOnly} configuration.
* @since 2.3.0 * @since 2.3.0

@ -56,7 +56,7 @@ class NativeImagePluginActionIntegrationTests {
@TestTemplate @TestTemplate
void reachabilityMetadataConfigurationFilesAreCopiedToJar() throws IOException { void reachabilityMetadataConfigurationFilesAreCopiedToJar() throws IOException {
writeDummySpringApplicationAotProcessorMainClass(); writeDummySpringApplicationAotProcessorMainClass();
BuildResult result = this.gradleBuild.build("bootJar"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1").build("bootJar");
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs"); File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"); File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar");
@ -74,7 +74,7 @@ class NativeImagePluginActionIntegrationTests {
writeDummySpringApplicationAotProcessorMainClass(); writeDummySpringApplicationAotProcessorMainClass();
FileSystemUtils.copyRecursively(new File("src/test/resources/reachability-metadata-repository"), FileSystemUtils.copyRecursively(new File("src/test/resources/reachability-metadata-repository"),
new File(this.gradleBuild.getProjectDir(), "reachability-metadata-repository")); new File(this.gradleBuild.getProjectDir(), "reachability-metadata-repository"));
BuildResult result = this.gradleBuild.build("bootJar"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1").build("bootJar");
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs"); File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"); File jarFile = new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar");
@ -90,27 +90,31 @@ class NativeImagePluginActionIntegrationTests {
@TestTemplate @TestTemplate
void bootBuildImageIsConfiguredToBuildANativeImage() { void bootBuildImageIsConfiguredToBuildANativeImage() {
writeDummySpringApplicationAotProcessorMainClass(); writeDummySpringApplicationAotProcessorMainClass();
BuildResult result = this.gradleBuild.build("bootBuildImageConfiguration"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
.build("bootBuildImageConfiguration");
assertThat(result.getOutput()).contains("paketobuildpacks/builder:tiny").contains("BP_NATIVE_IMAGE = true"); assertThat(result.getOutput()).contains("paketobuildpacks/builder:tiny").contains("BP_NATIVE_IMAGE = true");
} }
@TestTemplate @TestTemplate
void developmentOnlyDependenciesDoNotAppearInNativeImageClasspath() { void developmentOnlyDependenciesDoNotAppearInNativeImageClasspath() {
writeDummySpringApplicationAotProcessorMainClass(); writeDummySpringApplicationAotProcessorMainClass();
BuildResult result = this.gradleBuild.build("checkNativeImageClasspath"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
.build("checkNativeImageClasspath");
assertThat(result.getOutput()).doesNotContain("commons-lang"); assertThat(result.getOutput()).doesNotContain("commons-lang");
} }
@TestTemplate @TestTemplate
void classesGeneratedDuringAotProcessingAreOnTheNativeImageClasspath() { void classesGeneratedDuringAotProcessingAreOnTheNativeImageClasspath() {
BuildResult result = this.gradleBuild.build("checkNativeImageClasspath"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
.build("checkNativeImageClasspath");
assertThat(result.getOutput()).contains(projectPath("build/classes/java/aot"), assertThat(result.getOutput()).contains(projectPath("build/classes/java/aot"),
projectPath("build/resources/aot"), projectPath("build/generated/aotClasses")); projectPath("build/resources/aot"), projectPath("build/generated/aotClasses"));
} }
@TestTemplate @TestTemplate
void classesGeneratedDuringAotTestProcessingAreOnTheTestNativeImageClasspath() { void classesGeneratedDuringAotTestProcessingAreOnTheTestNativeImageClasspath() {
BuildResult result = this.gradleBuild.build("checkTestNativeImageClasspath"); BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("8.2-rc-1")
.build("checkTestNativeImageClasspath");
assertThat(result.getOutput()).contains(projectPath("build/classes/java/aotTest"), assertThat(result.getOutput()).contains(projectPath("build/classes/java/aotTest"),
projectPath("build/resources/aotTest"), projectPath("build/generated/aotTestClasses")); projectPath("build/resources/aotTest"), projectPath("build/generated/aotTestClasses"));
} }

@ -4,7 +4,9 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
applicationName = 'custom' application {
applicationName = 'custom'
}
bootJar { bootJar {
mainClass = 'com.example.ExampleApplication' mainClass = 'com.example.ExampleApplication'

@ -4,7 +4,9 @@ plugins {
if (project.hasProperty('applyApplicationPlugin')) { if (project.hasProperty('applyApplicationPlugin')) {
apply plugin: 'application' apply plugin: 'application'
applicationDefaultJvmArgs = ['-Dcom.example.a=alpha', '-Dcom.example.b=bravo'] application {
applicationDefaultJvmArgs = ['-Dcom.example.a=alpha', '-Dcom.example.b=bravo']
}
} }
task('taskExists') { task('taskExists') {

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,5 +3,7 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
imageName = "example/test-image-custom" imageName = "example/test-image-custom"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
imageName = "example/test-image-name" imageName = "example/test-image-name"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootJar { bootJar {
launchScript() launchScript()

@ -7,8 +7,10 @@ if (project.hasProperty('applyWarPlugin')) {
apply plugin: 'war' apply plugin: 'war'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -9,8 +9,10 @@ if (project.hasProperty('applyWarPlugin')) {
apply plugin: 'war' apply plugin: 'war'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,8 +3,10 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -7,8 +7,10 @@ if (project.hasProperty('applyWarPlugin')) {
apply plugin: 'war' apply plugin: 'war'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"

@ -3,10 +3,12 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
sourceCompatibility = '1.8' java {
targetCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bootBuildImage { bootBuildImage {
builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1" builder = "projects.registry.vmware.com/springboot/spring-boot-cnb-builder:0.0.1"
publish = true publish = true
} }

@ -4,4 +4,6 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
mainClassName = 'com.example.CustomMain' application {
mainClass = 'com.example.CustomMain'
}

@ -4,4 +4,6 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
mainClassName = 'com.example.CustomMain' application {
mainClass = 'com.example.CustomMain'
}

@ -3,4 +3,6 @@ plugins {
id 'org.springframework.boot' version '{version}' id 'org.springframework.boot' version '{version}'
} }
mainClassName = 'com.example.bootrun.main.CustomMainClass' application {
mainClass = 'com.example.bootrun.main.CustomMainClass'
}

@ -32,7 +32,7 @@ public final class GradleVersions {
} }
public static List<String> allCompatible() { public static List<String> allCompatible() {
return Arrays.asList("7.5.1", GradleVersion.current().getVersion(), "8.0.2", "8.1.1"); return Arrays.asList("7.5.1", GradleVersion.current().getVersion(), "8.0.2", "8.1.1", "8.2-rc-1");
} }
public static String minimumCompatible() { public static String minimumCompatible() {

Loading…
Cancel
Save