From 1e8d29f7aadb28e61db20b9abfcad9a86f3edc12 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 22 Feb 2022 18:11:51 +0000 Subject: [PATCH] Configure Kotlin compilation JVM target by convention Closes gh-29952 --- .../boot/build/KotlinConventions.java | 4 +++- spring-boot-project/spring-boot/build.gradle | 12 ------------ .../build.gradle | 12 ------------ 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/KotlinConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/KotlinConventions.java index 7611d71e1aa..35b82a47d06 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/KotlinConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/KotlinConventions.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 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. @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile; *
  • {@link KotlinCompile} tasks are configured to: * @@ -48,6 +49,7 @@ class KotlinConventions { KotlinJvmOptions kotlinOptions = compile.getKotlinOptions(); kotlinOptions.setApiVersion("1.3"); kotlinOptions.setLanguageVersion("1.3"); + kotlinOptions.setJvmTarget("1.8"); kotlinOptions.setAllWarningsAsErrors(true); List freeCompilerArgs = new ArrayList<>(compile.getKotlinOptions().getFreeCompilerArgs()); freeCompilerArgs.add("-Xsuppress-version-warnings"); diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle index c5d8a655364..5e7389cdaec 100644 --- a/spring-boot-project/spring-boot/build.gradle +++ b/spring-boot-project/spring-boot/build.gradle @@ -161,18 +161,6 @@ sourceSets { } } -compileKotlin { - kotlinOptions { - jvmTarget = 1.8 - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = 1.8 - } -} - toolchain { testJvmArgs.add("--add-opens=java.base/java.net=ALL-UNNAMED") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle index 8d38e295b89..101d961ffb4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle @@ -6,18 +6,6 @@ plugins { description = "Spring Boot WebFlux coroutines smoke test" -compileKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "1.8" - } -} - dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-webflux")) implementation("com.fasterxml.jackson.module:jackson-module-kotlin")