Browse Source

iOS cache kind warning to error (#3667)

Co-authored-by: Alexey Tsvetkov <alexey.tsvetkov@jetbrains.com>
pull/3673/head
dima.avdeev 1 year ago committed by GitHub
parent
commit
679f2821c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt
  2. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/service/ConfigurationProblemReporterService.kt
  3. 52
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt
  4. 1
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersions.kt
  5. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt
  6. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/build.gradle
  7. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/gradle.properties
  8. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/settings.gradle
  9. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/src/commonMain/kotlin/App.kt
  10. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/subproject/build.gradle
  11. 0
      gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/subproject/src/commonMain/kotlin/App.kt

13
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureNativeCompilerCaching.kt

@ -8,7 +8,6 @@ package org.jetbrains.compose.experimental.internal
import org.gradle.api.Project
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
import org.jetbrains.compose.internal.mppExt
import org.jetbrains.compose.internal.service.ConfigurationProblemReporterService
import org.jetbrains.compose.internal.utils.KGPPropertyProvider
import org.jetbrains.compose.internal.utils.configureEachWithType
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
@ -65,24 +64,20 @@ private fun KotlinNativeTarget.checkExplicitCacheKind() {
for (provider in propertyProviders) {
val value = provider.valueOrNull(cacheKindProperty)
if (value != null) {
ConfigurationProblemReporterService.reportProblem(
project,
explicitCacheKindWarningMessage(cacheKindProperty, value, provider)
)
return
error(explicitCacheKindErrorMessage(cacheKindProperty, value, provider))
}
}
}
}
private fun explicitCacheKindWarningMessage(
private fun explicitCacheKindErrorMessage(
cacheKindProperty: String,
value: String,
provider: KGPPropertyProvider
) = """
|Warning: '$cacheKindProperty' is explicitly set to '$value'.
|Error: '$cacheKindProperty' is explicitly set to '$value'.
|This option significantly slows the Kotlin/Native compiler.
|Compose Multiplatform Gradle plugin manages this property automatically based on a Kotlin compiler version being used.
|In future versions of Compose Multiplatform this warning will become an error.
| * Recommended action: remove explicit '$cacheKindProperty=$value' from ${provider.location}.
| * Alternative action: disable cache kind management by adding '$COMPOSE_NATIVE_MANAGE_CACHE_KIND=false' to your 'gradle.properties'.
""".trimMargin()

2
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/service/ConfigurationProblemReporterService.kt

@ -51,7 +51,7 @@ abstract class ConfigurationProblemReporterService : AbstractComposeMultiplatfor
.parameters.fn()
}
fun reportProblem(project: Project, message: String) {
fun reportWarning(project: Project, message: String) {
configureParameters(project) { warnings.add(message) }
}

52
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt

@ -148,11 +148,11 @@ class GradlePluginTest : GradlePluginTestBase() {
}
@Test
fun nativeCacheKindWarning() {
fun nativeCacheKindError() {
Assumptions.assumeTrue(currentOS == OS.MacOS)
fun withNativeCacheKindWarningProject(kotlinVersion: String, fn: TestProject.() -> Unit) {
fun withNativeCacheKindErrorProject(kotlinVersion: String, fn: TestProject.() -> Unit) {
with(testProject(
TestProjects.nativeCacheKindWarning,
TestProjects.nativeCacheKindError,
defaultTestEnvironment.copy(kotlinVersion = kotlinVersion)
)) {
fn()
@ -164,46 +164,44 @@ class GradlePluginTest : GradlePluginTestBase() {
fun testKotlinVersion(kotlinVersion: String) {
val args = arrayOf("help")
val commonPartOfWarning = "Compose Multiplatform Gradle plugin manages this property automatically"
withNativeCacheKindWarningProject(kotlinVersion = kotlinVersion) {
withNativeCacheKindErrorProject(kotlinVersion = kotlinVersion) {
gradle(*args).checks {
check.logDoesntContain("Warning: 'kotlin.native.cacheKind")
check.logDoesntContain("Error: 'kotlin.native.cacheKind")
check.logDoesntContain(commonPartOfWarning)
}
}
withNativeCacheKindWarningProject(kotlinVersion = kotlinVersion) {
gradle(*args, "-Pkotlin.native.cacheKind=none").checks {
check.logContainsOnce("Warning: 'kotlin.native.cacheKind' is explicitly set to 'none'")
check.logContainsOnce(commonPartOfWarning)
withNativeCacheKindErrorProject(kotlinVersion = kotlinVersion) {
gradleFailure(*args, "-Pkotlin.native.cacheKind=none").checks {
check.logContains("Error: 'kotlin.native.cacheKind' is explicitly set to 'none'")
check.logContains(commonPartOfWarning)
}
gradle(*args, "-Pkotlin.native.cacheKind=none").checks {
check.logContainsOnce("Warning: 'kotlin.native.cacheKind' is explicitly set to 'none'")
check.logContainsOnce(commonPartOfWarning)
gradleFailure(*args, "-Pkotlin.native.cacheKind=none").checks {
check.logContains("Error: 'kotlin.native.cacheKind' is explicitly set to 'none'")
check.logContains(commonPartOfWarning)
}
}
withNativeCacheKindWarningProject(kotlinVersion = kotlinVersion) {
gradle(*args, "-Pkotlin.native.cacheKind=static").checks {
check.logContainsOnce("Warning: 'kotlin.native.cacheKind' is explicitly set to 'static'")
check.logContainsOnce(commonPartOfWarning)
withNativeCacheKindErrorProject(kotlinVersion = kotlinVersion) {
gradleFailure(*args, "-Pkotlin.native.cacheKind=static").checks {
check.logContains("Error: 'kotlin.native.cacheKind' is explicitly set to 'static'")
check.logContains(commonPartOfWarning)
}
}
withNativeCacheKindWarningProject(kotlinVersion = kotlinVersion) {
gradle(*args, "-Pkotlin.native.cacheKind.iosX64=none").checks {
check.logContainsOnce("Warning: 'kotlin.native.cacheKind.iosX64' is explicitly set to 'none'")
check.logContainsOnce(commonPartOfWarning)
withNativeCacheKindErrorProject(kotlinVersion = kotlinVersion) {
gradleFailure(*args, "-Pkotlin.native.cacheKind.iosX64=none").checks {
check.logContains("Error: 'kotlin.native.cacheKind.iosX64' is explicitly set to 'none'")
check.logContains(commonPartOfWarning)
}
}
withNativeCacheKindWarningProject(kotlinVersion = kotlinVersion) {
gradle(*args, "-Pkotlin.native.cacheKind.iosX64=static").checks {
check.logContainsOnce("Warning: 'kotlin.native.cacheKind.iosX64' is explicitly set to 'static'")
check.logContainsOnce(commonPartOfWarning)
withNativeCacheKindErrorProject(kotlinVersion = kotlinVersion) {
gradleFailure(*args, "-Pkotlin.native.cacheKind.iosX64=static").checks {
check.logContains("Error: 'kotlin.native.cacheKind.iosX64' is explicitly set to 'static'")
check.logContains(commonPartOfWarning)
}
}
}
testKotlinVersion(TestKotlinVersions.v1_8_20)
testKotlinVersion(TestKotlinVersions.v1_9_0)
testKotlinVersion(TestKotlinVersions.v1_9_20_Beta)
}
@Test

1
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersions.kt

@ -9,4 +9,5 @@ object TestKotlinVersions {
val Default = TestProperties.composeCompilerCompatibleKotlinVersion
val v1_8_20 = "1.8.20"
val v1_9_0 = "1.9.0"
val v1_9_20_Beta = "1.9.20-Beta"
}

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt

@ -29,5 +29,5 @@ object TestProjects {
const val iosResources = "misc/iosResources"
const val iosMokoResources = "misc/iosMokoResources"
const val nativeCacheKind = "misc/nativeCacheKind"
const val nativeCacheKindWarning = "misc/nativeCacheKindWarning"
const val nativeCacheKindError = "misc/nativeCacheKindError"
}

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/build.gradle → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/build.gradle

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/gradle.properties → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/gradle.properties

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/settings.gradle → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/settings.gradle

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/src/commonMain/kotlin/App.kt → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/src/commonMain/kotlin/App.kt

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/subproject/build.gradle → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/subproject/build.gradle

0
gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindWarning/subproject/src/commonMain/kotlin/App.kt → gradle-plugins/compose/src/test/test-projects/misc/nativeCacheKindError/subproject/src/commonMain/kotlin/App.kt

Loading…
Cancel
Save