Skip to content

Commit

Permalink
Replace warnings with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyTsvetkov committed Aug 15, 2023
1 parent 6127a29 commit e394974
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 50 deletions.
3 changes: 1 addition & 2 deletions examples/chat/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/chat/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/codeviewer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/codeviewer/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/falling-balls/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/falling-balls/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/imageviewer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.native.useEmbeddableCompilerJar=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.5.0-dev1114
compose.version=1.5.0-beta02
2 changes: 0 additions & 2 deletions examples/imageviewer/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"

}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/minesweeper/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
12 changes: 1 addition & 11 deletions examples/minesweeper/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ kotlin {
jvm("desktop")

ios()
iosSimulatorArm64() {
// TODO: remove after 1.5 release
binaries.forEach {
it.freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
"-linker-option", "-framework", "-linker-option", "CoreGraphics",
)
}
}
iosSimulatorArm64()

js(IR) {
browser()
Expand Down Expand Up @@ -54,7 +45,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/todoapp-lite/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/todoapp-lite/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/visual-effects/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/visual-effects/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
3 changes: 1 addition & 2 deletions examples/widgets-gallery/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ org.gradle.jvmargs=-Xmx3g
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.0
agp.version=7.1.3
compose.version=1.4.3
compose.version=1.5.0-beta02
1 change: 0 additions & 1 deletion examples/widgets-gallery/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ kotlin {
baseName = "shared"
isStatic = true
}
extraSpecAttributes["resources"] = "['src/commonMain/resources/**', 'src/iosMain/resources/**']"
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ private fun KotlinNativeTarget.checkCacheKindUserValueIsNotNone() {
val value = provider.valueOrNull(cacheKindProperty)
if (value != null) {
if (value.equals(NONE_VALUE, ignoreCase = true)) {
ComposeMultiplatformBuildService
.getInstance(project)
.warnOnceAfterBuild(cacheKindPropertyWarningMessage(cacheKindProperty, provider))
error(cacheKindPropertyWarningMessage(cacheKindProperty, provider))
}
return
}
Expand All @@ -60,13 +58,13 @@ private fun cacheKindPropertyWarningMessage(
cacheKindProperty: String,
provider: KGPPropertyProvider
) = """
|Warning: '$cacheKindProperty' is explicitly set to `none`.
|'$cacheKindProperty' is explicitly set to `none`.
|This option significantly slows the Kotlin/Native compiler.
|Compose Multiplatform Gradle plugin can set this property automatically,
|when it is necessary.
| * Recommended action: remove explicit '$cacheKindProperty=$NONE_VALUE' from ${provider.location}.
| * Alternative action: if you are sure you need '$cacheKindProperty=$NONE_VALUE', disable
|this warning by adding '$COMPOSE_NATIVE_MANAGE_CACHE_KIND=false' to your 'gradle.properties'.
|this error by adding '$COMPOSE_NATIVE_MANAGE_CACHE_KIND=false' to your 'gradle.properties'.
""".trimMargin()

private fun KotlinNativeTarget.configureTargetCompilerCache(kotlinVersion: KotlinVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ private fun SyncIosResourcesContext.configureCocoapodsResourcesAttribute() {
val specAttributes = cocoapodsExt.extraSpecAttributes
val resourcesSpec = specAttributes[RESOURCES_SPEC_ATTR]
if (!resourcesSpec.isNullOrBlank()) {
project.logger.warn("Warning: kotlin.cocoapods.extraSpecAttributes[\"resources\"] is ignored by Compose Multiplatform's resource synchronization for iOS")
error("""
|Kotlin.cocoapods.extraSpecAttributes["resources"] is not compatible with Compose Multiplatform's resources management for iOS.
| * Recommended action: remove extraSpecAttributes["resources"] from '${project.buildFile}' and run '${project.path}:podInstall' once;
| * Alternative action: turn off Compose Multiplatform's resources management for iOS by adding '${IosGradleProperties.SYNC_RESOURCES_PROPERTY}=false' to your gradle.properties;
""".trimMargin())
}
cocoapodsExt.framework {
val syncDir = syncDirFor(this).get().asFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,19 @@ class GradlePluginTest : GradlePluginTestBase() {
defaultTestEnvironment.copy(kotlinVersion = kotlinVersion)
)

val cacheKindWarning = "Warning: 'kotlin.native.cacheKind' is explicitly set to `none`"
val cacheKindError = "'kotlin.native.cacheKind' is explicitly set to `none`"

val args = arrayOf("build", "--dry-run", "-Pkotlin.native.cacheKind=none")
with(nativeCacheKindWarningProject(kotlinVersion = TestKotlinVersions.v1_8_20)) {
gradle(*args).checks {
check.logContainsOnce(cacheKindWarning)
}
// check that the warning is shown even when the configuration is loaded from cache
gradle(*args).checks {
check.logContainsOnce(cacheKindWarning)
gradleFailure(*args).checks {
check.logContains(cacheKindError)
}
}
testWorkDir.deleteRecursively()
testWorkDir.mkdirs()
with(nativeCacheKindWarningProject(kotlinVersion = TestKotlinVersions.v1_9_0) ) {
gradle(*args).checks {
check.logContainsOnce(cacheKindWarning)
gradleFailure(*args).checks {
check.logContains(cacheKindError)
}
}
}
Expand Down

0 comments on commit e394974

Please sign in to comment.