diff --git a/build.gradle.kts b/build.gradle.kts index cc03af7656b..9da58de1b18 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -321,6 +321,23 @@ extra["compilerModulesForJps"] = listOf( ":compiler:compiler.version" ) +// TODO: fix remaining warnings and remove this property. +extra["tasksWithWarnings"] = listOf( + ":kotlin-stdlib:compileTestKotlin", + ":kotlin-stdlib-jdk7:compileTestKotlin", + ":kotlin-stdlib-jdk8:compileTestKotlin", + ":compiler:frontend:compileKotlin", + ":compiler:fir:tree:compileKotlin", + ":compiler:fir:resolve:compileKotlin", + ":compiler:fir:checkers:compileKotlin", + ":compiler:fir:java:compileKotlin", + ":plugins:uast-kotlin:compileKotlin", + ":plugins:uast-kotlin:compileTestKotlin", + ":plugins:uast-kotlin-idea:compileKotlin" +) + +val tasksWithWarnings: List by extra + val coreLibProjects = listOfNotNull( ":kotlin-stdlib", ":kotlin-stdlib-common", @@ -454,6 +471,21 @@ allprojects { } } + if (!kotlinBuildProperties.isInJpsBuildIdeaSync) { + // For compiler and stdlib, allWarningsAsErrors is configured in the corresponding "root" projects + // (compiler/build.gradle.kts and libraries/commonConfiguration.gradle). + val projectsWithWarningsAsErrors = listOf("core", "plugins").map { File(it).absoluteFile } + if (projectsWithWarningsAsErrors.any(projectDir::startsWith)) { + tasks.withType { + if (path !in tasksWithWarnings) { + kotlinOptions { + allWarningsAsErrors = true + } + } + } + } + } + tasks.withType(VerificationTask::class.java as Class) { (this as VerificationTask).ignoreFailures = ignoreTestFailures } diff --git a/compiler/build.gradle.kts b/compiler/build.gradle.kts index 4afd3561e5e..19e9a8649c0 100644 --- a/compiler/build.gradle.kts +++ b/compiler/build.gradle.kts @@ -10,6 +10,8 @@ plugins { val compilerModules: Array by rootProject.extra val otherCompilerModules = compilerModules.filter { it != path } +val tasksWithWarnings: List by rootProject.extra + val effectSystemEnabled: Boolean by rootProject.extra val newInferenceEnabled: Boolean by rootProject.extra @@ -85,6 +87,16 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) { idea { this.module.generatedSourceDirs.add(generationRoot) } +} else { + allprojects { + tasks.withType> { + if (path !in tasksWithWarnings) { + kotlinOptions { + allWarningsAsErrors = true + } + } + } + } } projectTest(parallel = true) { diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 5605a840822..a450e082560 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -57,7 +57,7 @@ tasks.withType> { kotlinOptions { languageVersion = "1.3" apiVersion = "1.3" - freeCompilerArgs += "-Xskip-prerelease-check" + freeCompilerArgs = freeCompilerArgs - "-progressive" + "-Xskip-prerelease-check" } } diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index fad6c58bdb2..456b15caa6b 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -9,6 +9,8 @@ ext.configureJavaOnlyJvm6Project = { Project project -> } } +List tasksWithWarnings = (List) rootProject.ext.get("tasksWithWarnings") + ext.configureJvm6Project = { Project project -> project.configure(project) { configurations { @@ -34,6 +36,14 @@ ext.configureJvm6Project = { Project project -> executable = "$JDK_16/bin/java" } } + + project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile.class) { task -> + if (!tasksWithWarnings.contains(task.path)) { + task.kotlinOptions { + allWarningsAsErrors = true + } + } + } } ext.compileJava9Sources = { Project project, String moduleName, Collection moduleOutputs = [project.sourceSets.main.output] -> diff --git a/plugins/scripting/scripting-compiler/build.gradle.kts b/plugins/scripting/scripting-compiler/build.gradle.kts index e04a46c3399..128a2797476 100644 --- a/plugins/scripting/scripting-compiler/build.gradle.kts +++ b/plugins/scripting/scripting-compiler/build.gradle.kts @@ -47,7 +47,7 @@ tasks.withType> { kotlinOptions { languageVersion = "1.3" apiVersion = "1.3" - freeCompilerArgs += "-Xskip-metadata-version-check" + freeCompilerArgs = freeCompilerArgs - "-progressive" + "-Xskip-metadata-version-check" } }