Merge branch '2.3.x' into 2.4.x

Closes gh-26353
pull/26435/head
Andy Wilkinson 4 years ago
commit 75bb50bd02

@ -64,7 +64,6 @@ import org.springframework.boot.build.toolchain.ToolchainPlugin;
* plugin is applied: * plugin is applied:
* *
* <ul> * <ul>
* <li>{@code sourceCompatibility} is set to {@code 1.8}
* <li>{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin * <li>{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin
* Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test * Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test
* Retry} plugins are applied * Retry} plugins are applied
@ -79,8 +78,12 @@ import org.springframework.boot.build.toolchain.ToolchainPlugin;
* {@link JavaPlugin} applied * {@link JavaPlugin} applied
* <li>{@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured * <li>{@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured
* to use UTF-8 encoding * to use UTF-8 encoding
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters} and, when * <li>{@link JavaCompile} tasks are configured:
* compiling with Java 8, to: * <ul>
* <li>to use {@code -parameters}
* <li>with source and target compatibility of 1.8
* </ul>
* <li>When building with Java 8, {@link JavaCompile} tasks are also configured to:
* <ul> * <ul>
* <li>Treat warnings as errors * <li>Treat warnings as errors
* <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags} * <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags}
@ -107,11 +110,12 @@ import org.springframework.boot.build.toolchain.ToolchainPlugin;
*/ */
class JavaConventions { class JavaConventions {
private static final String SOURCE_AND_TARGET_COMPATIBILITY = "1.8";
void apply(Project project) { void apply(Project project) {
project.getPlugins().withType(JavaBasePlugin.class, (java) -> { project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
project.getPlugins().apply(TestFailuresPlugin.class); project.getPlugins().apply(TestFailuresPlugin.class);
configureSpringJavaFormat(project); configureSpringJavaFormat(project);
project.setProperty("sourceCompatibility", "1.8");
configureJavaCompileConventions(project); configureJavaCompileConventions(project);
configureJavadocConventions(project); configureJavadocConventions(project);
configureTestConventions(project); configureTestConventions(project);
@ -137,7 +141,7 @@ class JavaConventions {
jar.manifest((manifest) -> { jar.manifest((manifest) -> {
Map<String, Object> attributes = new TreeMap<>(); Map<String, Object> attributes = new TreeMap<>();
attributes.put("Automatic-Module-Name", project.getName().replace("-", ".")); attributes.put("Automatic-Module-Name", project.getName().replace("-", "."));
attributes.put("Build-Jdk-Spec", project.property("sourceCompatibility")); attributes.put("Build-Jdk-Spec", SOURCE_AND_TARGET_COMPATIBILITY);
attributes.put("Built-By", "Spring"); attributes.put("Built-By", "Spring");
attributes.put("Implementation-Title", attributes.put("Implementation-Title",
determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar)); determineImplementationTitle(project, sourceJarTaskNames, javadocJarTaskNames, jar));
@ -198,8 +202,8 @@ class JavaConventions {
private void configureJavaCompileConventions(Project project) { private void configureJavaCompileConventions(Project project) {
project.getTasks().withType(JavaCompile.class, (compile) -> { project.getTasks().withType(JavaCompile.class, (compile) -> {
compile.getOptions().setEncoding("UTF-8"); compile.getOptions().setEncoding("UTF-8");
compile.setSourceCompatibility("1.8"); compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
compile.setTargetCompatibility("1.8"); compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
List<String> args = compile.getOptions().getCompilerArgs(); List<String> args = compile.getOptions().getCompilerArgs();
if (!args.contains("-parameters")) { if (!args.contains("-parameters")) {
args.add("-parameters"); args.add("-parameters");

Loading…
Cancel
Save