Build: suppress deprecated JVM target warning globally

There seems to be no point in configuring the compiler argument per
project. This argument will be deleted soon anyway, when we remove
support for JDK 1.6 & 1.7.

Also remove `disableDeprecatedJvmTargetWarning`. It didn't have any
effect in all modules where it was applied because these modules
reassign `freeCompilerArgs` anyway, with
`-Xsuppress-deprecated-jvm-target-warning` in it.
This commit is contained in:
Alexander Udalov
2021-07-25 21:32:34 +02:00
parent 91c39ed01c
commit 0a9498f7e2
33 changed files with 6 additions and 133 deletions

View File

@@ -459,7 +459,8 @@ allprojects {
val jvmCompilerArgs = listOf(
"-Xjvm-default=compatibility",
"-Xno-optimized-callable-references",
"-Xno-kotlin-nothing-value-exception"
"-Xno-kotlin-nothing-value-exception",
"-Xsuppress-deprecated-jvm-target-warning" // Remove as soon as there are no modules for JDK 1.6 & 1.7
)
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> {

View File

@@ -9,12 +9,8 @@ import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.gradle.process.CommandLineArgumentProvider
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@JvmOverloads
fun Project.configureJava9Compilation(
@@ -59,17 +55,3 @@ private class Java9AdditionalArgumentsProvider(
"-Xlint:-requires-transitive-automatic" // suppress automatic module transitive dependencies in kotlin.test
)
}
fun Project.disableDeprecatedJvmTargetWarning() {
if (!kotlinBuildProperties.disableWerror) {
val tasksWithWarnings: List<String> by rootProject.extra
tasks.withType<KotlinCompile>().configureEach {
if (!tasksWithWarnings.contains(path)) {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}
}
}
}

View File

@@ -16,9 +16,3 @@ sourceSets {
}
testsJar {}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -13,9 +13,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -15,9 +15,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -19,9 +19,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -5,8 +5,6 @@ plugins {
id("jps-compatible")
}
// Only compilation tasks should use JDK 1.6
project.disableDeprecatedJvmTargetWarning()
tasks
.matching { it.name == "compileKotlin" && it is KotlinCompile }
.configureEach {

View File

@@ -16,9 +16,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -15,9 +15,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -14,9 +14,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -17,9 +17,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -13,9 +13,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -14,9 +14,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -13,9 +13,3 @@ sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -3,7 +3,6 @@ description = 'Kotlin Test JUnit'
apply plugin: 'kotlin-platform-jvm'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)

View File

@@ -33,7 +33,6 @@ configureJavadocJar()
compileKotlin {
kotlinOptions.freeCompilerArgs = [
"-Xallow-kotlin-package",
"-Xsuppress-deprecated-jvm-target-warning",
]
kotlinOptions.moduleName = project.name
}
@@ -41,7 +40,6 @@ compileKotlin {
compileTestKotlin {
kotlinOptions.freeCompilerArgs = [
"-Xallow-kotlin-package",
"-Xsuppress-deprecated-jvm-target-warning",
]
}

View File

@@ -5,7 +5,6 @@ apply plugin: 'kotlin-platform-jvm'
archivesBaseName = 'kotlin-test'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)

View File

@@ -4,7 +4,6 @@ apply plugin: 'kotlin-platform-jvm'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_7)
JvmToolchain.updateJvmTarget(project, "1.6")
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)

View File

@@ -23,9 +23,3 @@ dependencies {
compileOnly(project(":core:metadata"))
compileOnly(protobufLite())
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -52,12 +52,6 @@ dependencies {
testRuntimeOnly(project(":kotlin-reflect"))
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}
if (deployVersion != null) {
publish()
}

View File

@@ -3,7 +3,6 @@ description = ''
apply plugin: 'kotlin'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)

View File

@@ -18,7 +18,7 @@ sourceSets {
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += listOf(
"-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning"
"-Xallow-kotlin-package"
)
}

View File

@@ -43,7 +43,7 @@ sourceSets {
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += listOf(
"-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning"
"-Xallow-kotlin-package"
)
}

View File

@@ -19,7 +19,7 @@ sourceSets {
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += listOf(
"-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning"
"-Xallow-kotlin-package"
)
}

View File

@@ -19,8 +19,7 @@ sourceSets {
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions.freeCompilerArgs += listOf(
"-Xallow-kotlin-package",
"-Xsuppress-deprecated-jvm-target-warning"
"-Xallow-kotlin-package"
)
}

View File

@@ -4,7 +4,6 @@ apply plugin: 'kotlin'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_7)
JvmToolchain.updateJvmTarget(project, "1.6")
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
configurePublishing(project)
configureSourcesJar()

View File

@@ -59,7 +59,6 @@ tasks.withType<KotlinCompile> {
freeCompilerArgs += listOf(
"-Xallow-kotlin-package",
"-Xmulti-platform",
"-Xsuppress-deprecated-jvm-target-warning",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.contracts.ExperimentalContracts"
)

View File

@@ -5,7 +5,6 @@ apply plugin: 'kotlin-platform-jvm'
archivesBaseName = 'kotlin-stdlib'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
configurePublishing(project)
configureJavadocJar()

View File

@@ -3,7 +3,6 @@ description = 'Kotlin annotations for JVM'
apply plugin: 'kotlin'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
configurePublishing(project)

View File

@@ -3,7 +3,6 @@ description 'Kotlin Script Runtime'
apply plugin: 'kotlin'
JvmToolchain.configureJvmToolchain(project, JdkMajorVersion.JDK_1_6)
LibrariesCommon.disableDeprecatedJvmTargetWarning(project)
configurePublishing(project)

View File

@@ -22,9 +22,3 @@ publish()
runtimeJar()
sourcesJar()
javadocJar()
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -21,9 +21,3 @@ publish()
runtimeJar()
sourcesJar()
javadocJar()
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}

View File

@@ -25,9 +25,3 @@ publish {
runtimeJar()
sourcesJar()
javadocJar()
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning"
}
}