[Gradle] skip CheckKotlinGradlePluginConfigurationErrors if no errors
- Add an `onlyIf {}` check so CheckKotlinGradlePluginConfigurationErrors
won't run unless there are errors,
which helps writing integration tests and preventing IJ warnings.
- remove unnecessary sequence when fetching DiagnosticsForProject
- update test assertions relating to
CheckKotlinGradlePluginConfigurationErrors
^KT-61943 Fixed
This commit is contained in:
committed by
Space Team
parent
19283048a8
commit
4b48f15d0f
+9
@@ -193,6 +193,15 @@ class MppDiagnosticsIt : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
fun testErrorDiagnosticUpToDateIfNoErrors(gradleVersion: GradleVersion) {
|
||||
project("errorDiagnosticUpToDateIfNoErrors", gradleVersion) {
|
||||
build("assemble") {
|
||||
assertTasksSkipped(":checkKotlinGradlePluginConfigurationErrors")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun TestProject.expectedOutputFile(suffix: String? = null): File {
|
||||
val suffixIfAny = if (suffix != null) "-$suffix" else ""
|
||||
return projectPath.resolve("expectedOutput$suffixIfAny.txt").toFile()
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "diagnostics-rendering-smoke"
|
||||
+1
-1
@@ -12,4 +12,4 @@ e: [CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonMain can't declare de
|
||||
|
||||
> Configure project :healthyProject
|
||||
|
||||
> Task :healthyProject:checkKotlinGradlePluginConfigurationErrors
|
||||
> Task :healthyProject:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||
|
||||
+1
-1
@@ -22,4 +22,4 @@ e: [CommonMainOrTestWithDependsOnDiagnostic | ERROR] commonMain can't declare de
|
||||
#diagnostic-end
|
||||
|
||||
|
||||
> Task :healthyProject:checkKotlinGradlePluginConfigurationErrors
|
||||
> Task :healthyProject:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||
|
||||
+1
-1
@@ -8,4 +8,4 @@ Stability and future compatibility of the build is not guaranteed.
|
||||
#diagnostic-end
|
||||
|
||||
|
||||
> Task :checkKotlinGradlePluginConfigurationErrors
|
||||
> Task :checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
> Configure project :
|
||||
|
||||
> Task :checkKotlinGradlePluginConfigurationErrors
|
||||
> Task :checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||
|
||||
+7
-2
@@ -15,6 +15,7 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.gradle.work.DisableCachingByDefault
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompileTool
|
||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||
import org.jetbrains.kotlin.gradle.utils.onlyIfCompat
|
||||
|
||||
@DisableCachingByDefault(
|
||||
because = "This task renders reported diagnostics; caching this task will hide diagnostics and obscure issues in the build"
|
||||
@@ -51,14 +52,18 @@ internal fun Project.locateOrRegisterCheckKotlinGradlePluginErrorsTask(): TaskPr
|
||||
task.errorDiagnostics.set(
|
||||
provider {
|
||||
kotlinToolingDiagnosticsCollector
|
||||
.getDiagnosticsForProject(this).asSequence()
|
||||
.getDiagnosticsForProject(this)
|
||||
.filter { it.severity == ToolingDiagnostic.Severity.ERROR }
|
||||
.toList()
|
||||
}
|
||||
)
|
||||
task.renderingOptions.set(ToolingDiagnosticRenderingOptions.forProject(this))
|
||||
task.description = DESCRIPTION
|
||||
task.group = LifecycleBasePlugin.VERIFICATION_GROUP
|
||||
|
||||
task.onlyIfCompat("errorDiagnostics are present") {
|
||||
require(it is CheckKotlinGradlePluginConfigurationErrors)
|
||||
!it.errorDiagnostics.orNull.isNullOrEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
taskProvider.addDependsOnFromTasksThatShouldFailWhenErrorsReported(tasks)
|
||||
|
||||
Reference in New Issue
Block a user