-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve DSL for setting a custom Compose Plugin (#2527)
* Improve DSL for setting a custom Compose Plugin Fixes #2459 Readme: #2526 1. Add `dependencies: Dependencies` extension that is accessible in `compose { }` block 2. Add `Dependencies.compiler` property that can return versions of Compose compiler used by the plugin: ``` compose { kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.7.20")) //kotlinCompilerPlugin.set(dependencies.compiler.auto) // determined by applied version of Kotlin. It is a default. } ``` 3. Add ability to set arguments for Compose Compiler. Now we can write: ``` compose { kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.7.20")) kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.7.21") } ``` 4. Remove checks for different targets We had a separate check for JS, when we released 1.2.0. It doesn't support Kotlin 1.7.20 at that moment. It is hard to refactor this feature in the new code, so I removed it. It is not needed now and it had an ugly code. When we will need it again, we'll write it again. 5. Remove the `compose.tests.androidx.compiler.version` property from gradle.properties and remove `defaultAndroidxCompilerEnvironment` Because they are used only in one test, and it seems there is no reason to use it in another place in the future * Discussions
- Loading branch information
Showing
21 changed files
with
255 additions
and
120 deletions.
There are no files selected for viewing
24 changes: 14 additions & 10 deletions
24
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatability.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
package org.jetbrains.compose | ||
|
||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType | ||
private const val KOTLIN_COMPATABILITY_LINK = | ||
"https://github.com/JetBrains/compose-jb/blob/master/VERSIONING.md#kotlin-compatibility" | ||
|
||
internal object ComposeCompilerCompatability { | ||
fun compilerVersionFor(kotlinVersion: String): ComposeCompilerVersion? = when (kotlinVersion) { | ||
"1.7.10" -> ComposeCompilerVersion("1.3.0") | ||
"1.7.20" -> ComposeCompilerVersion("1.3.2.1") | ||
else -> null | ||
private val kotlinToCompiler = sortedMapOf( | ||
"1.7.10" to "1.3.0", | ||
"1.7.20" to "1.3.2.1", | ||
) | ||
|
||
fun compilerVersionFor(kotlinVersion: String): String { | ||
return kotlinToCompiler[kotlinVersion] ?: throw RuntimeException( | ||
"This version of Compose Multiplatform doesn't support Kotlin " + | ||
"$kotlinVersion. " + | ||
"Please see $KOTLIN_COMPATABILITY_LINK " + | ||
"to know the latest supported version of Kotlin." | ||
) | ||
} | ||
} | ||
|
||
internal data class ComposeCompilerVersion( | ||
val version: String, | ||
val unsupportedPlatforms: Set<KotlinPlatformType> = emptySet() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.