Skip to content

Commit

Permalink
[3.x] update Kotlin to 1.9 (#5412)
Browse files Browse the repository at this point in the history
* resurect the 3.x branch

We needed Kotlin 1.9 to support new XCode command line options, which in turns needed other things

* add comment

* fix compose compilation

* update api dump

* fix errors

* update kotlin-compile-testing

* fix Gradle tests

* fix android layout
  • Loading branch information
martinbonnin committed Nov 30, 2023
1 parent 3c35b3d commit d940af8
Show file tree
Hide file tree
Showing 25 changed files with 341 additions and 1,106 deletions.
24 changes: 8 additions & 16 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension
import org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverGradleSubplugin

plugins {
`embedded-kotlin`
id("org.jetbrains.kotlin.jvm").version("1.9.21")
id("org.jetbrains.kotlin.plugin.sam.with.receiver").version("1.9.21")
id("java-gradle-plugin")
id("net.mbonnin.golatac").version("0.0.3")
}

plugins.apply(SamWithReceiverGradleSubplugin::class.java)
extensions.configure(SamWithReceiverExtension::class.java) {
annotations(HasImplicitReceiver::class.qualifiedName!!)
}
Expand All @@ -34,19 +33,12 @@ dependencies {

// We want the KSP plugin to use the version from the classpath and not force a newer version
// of the Gradle plugin
if (System.getProperty("idea.sync.active") == null) {
implementation(golatac.lib("kotlin.plugin"))
runtimeOnly(golatac.lib("ksp"))
// XXX: This is only needed for tests. We could have different build logic for different
// builds but this seems just overkill for now
runtimeOnly(golatac.lib("kotlin.allopen"))
runtimeOnly(golatac.lib("kotlinx.serialization.plugin"))
} else {
implementation(golatac.lib("kotlin.plugin.duringideasync"))
runtimeOnly(golatac.lib("ksp.duringideasync"))
runtimeOnly(golatac.lib("kotlin.allopen.duringideasync"))
runtimeOnly(golatac.lib("kotlinx.serialization.plugin.duringideasync"))
}
implementation(golatac.lib("kotlin.plugin"))
runtimeOnly(golatac.lib("ksp"))
// XXX: This is only needed for tests. We could have different build logic for different
// builds but this seems just overkill for now
runtimeOnly(golatac.lib("kotlin.allopen"))
runtimeOnly(golatac.lib("kotlinx.serialization.plugin"))

runtimeOnly(golatac.lib("sqldelight.plugin"))
runtimeOnly(golatac.lib("gradle.publish.plugin"))
Expand Down
3 changes: 2 additions & 1 deletion build-logic/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ kotlin.stdlib.default.dependency=false
# Enable the build cache
org.gradle.caching=true
# Enable the configuration cache
#org.gradle.unsafe.configuration-cache=true
#org.gradle.unsafe.configuration-cache=true
kotlin.mpp.applyDefaultHierarchyTemplate=false
12 changes: 11 additions & 1 deletion build-logic/src/main/kotlin/CompilerOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile

fun Project.configureJavaAndKotlinCompilers(treatWarningsAsErrors: Boolean = false) {
// For Kotlin JVM projects
Expand Down Expand Up @@ -32,9 +33,15 @@ fun Project.configureJavaAndKotlinCompilers(treatWarningsAsErrors: Boolean = fal
(project.extensions.findByName("kotlin")
as? org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension)?.run {
sourceSets.all {
languageSettings {
languageVersion = "1.5"
apiVersion = "1.5"
}
languageSettings.optIn("kotlin.RequiresOptIn")
languageSettings.optIn("com.apollographql.apollo3.annotations.ApolloExperimental")
languageSettings.optIn("com.apollographql.apollo3.annotations.ApolloInternal")
languageSettings.optIn("kotlinx.cinterop.UnsafeNumber")
languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}

Expand All @@ -56,7 +63,10 @@ fun Project.configureJavaAndKotlinCompilers(treatWarningsAsErrors: Boolean = fal
private fun Project.treatWarningsAsErrors() {
tasks.withType(KotlinCompile::class.java) {
kotlinOptions {
allWarningsAsErrors = true
/**
* sadly languageVersion = 1.5 outputs a warning that we can't selectively disable
*/
//allWarningsAsErrors = true
}
}
}
6 changes: 0 additions & 6 deletions build-logic/src/main/kotlin/Mpp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ private fun KotlinMultiplatformExtension.createAndConfigureAppleTargets(presetNa
return
}

if (System.getProperty("idea.sync.active") != null) {
// Early return. Inside intelliJ, only configure one target
targetFromPreset(presets.getByName(hostTarget), "apple")
return
}

val appleMain = sourceSets.create("appleMain")
val appleTest = sourceSets.create("appleTest")

Expand Down
1 change: 0 additions & 1 deletion build-logic/src/main/kotlin/Node.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ fun Project.configureNode() {
// See https://youtrack.jetbrains.com/issue/KT-47215
plugins.withType(YarnPlugin::class.java).configureEach {
project.extensions.getByType(YarnRootExtension::class.java).apply {
disableGranularWorkspaces()
// Drop the patch version because there shouldn't be any dependency change
lockFileDirectory = projectDir.resolve("kotlin-js-store-${project.getKotlinPluginVersion().substringBeforeLast(".")}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LibraryConventionPlugin : Plugin<Project> {
fun treatWarningsAsErrors(treatWarningsAsErrors: Boolean) {
project.tasks.withType(KotlinCompile::class.java).configureEach {
kotlinOptions {
allWarningsAsErrors = treatWarningsAsErrors
// allWarningsAsErrors = treatWarningsAsErrors
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android.useAndroidX=true

# Enable compatibility with non-hierarchical projects.
# See https://kotlinlang.org/docs/multiplatform-hierarchy.html#for-library-authors
kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.mpp.applyDefaultHierarchyTemplate=false

# Keep in sync with other projects
# Give more memory to the Gradle daemon
Expand Down
18 changes: 9 additions & 9 deletions gradle/libraries.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ antlr = "4.9.3"
apollo = "3.8.3-SNAPSHOT"
cache = "2.0.2"
# See https://developer.android.com/jetpack/androidx/releases/compose-kotlin
compose-compiler = "1.4.4"
dokka = "1.7.10"
compose-compiler = "1.5.4"
dokka = "1.9.0"
guava = "31.1-jre"
javaPoet = "1.13.0"
jetbrains-annotations = "23.0.0"
junit = "4.13.2"
kotlin-plugin-min = "1.5.0"
kotlin-plugin = "1.8.10"
kotlin-plugin-max = "1.8.10"
kotlin-plugin-min = "1.8.0"
kotlin-plugin = "1.9.20"
kotlin-plugin-max = "1.9.20"
kotlin-plugin-duringideasync = "1.6.10"
kotlin-stdlib = "1.6.21"
kotlin-stdlib = "1.9.20"
kotlinx-coroutines = "1.6.4"
kotlinx-datetime = "0.4.0"
kotlinx-serialization-json = "1.4.1"
ksp = "1.8.0-1.0.9"
ksp = "1.9.20-1.0.14"
ksp-duringideasync = "1.6.10-1.0.2"
ktor = "2.2.2"
moshi = "1.12.0"
Expand Down Expand Up @@ -68,7 +68,7 @@ apollo-rx2 = { group = "com.apollographql.apollo3", name = "apollo-rx2-support",
apollo-rx3-java = { group = "com.apollographql.apollo3", name = "apollo-rx3-support-java", version.ref = "apollo" }
apollo-testingsupport = { group = "com.apollographql.apollo3", name = "apollo-testing-support", version.ref = "apollo" }
assertj = { group = "org.assertj", name = "assertj-core", version = "3.21.0" }
atomicfu = { group = "org.jetbrains.kotlinx", name = "atomicfu", version = "0.17.0" }
atomicfu = { group = "org.jetbrains.kotlinx", name = "atomicfu", version = "0.21.0" }
benmanes-versions = { group = "com.github.ben-manes", name = "gradle-versions-plugin", version = "0.33.0" }
clikt = { group = "com.github.ajalt.clikt", name = "clikt", version = "3.4.0" }
compose-runtime = { group = "androidx.compose.runtime", name = "runtime", version = "1.3.3" }
Expand All @@ -92,7 +92,7 @@ jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version
junit = { group = "junit", name = "junit", version.ref = "junit" }
kotlin-allopen = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin-plugin" }
kotlin-allopen-duringideasync = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin-plugin-duringideasync" }
kotlin-compiletesting = { group = "com.github.tschuchortdev", name = "kotlin-compile-testing", version = "1.4.9" }
kotlin-compiletesting = { group = "com.github.tschuchortdev", name = "kotlin-compile-testing", version = "1.5.0" }
# The main kotlin version for build-logic and Gradle tests
kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin" }
# See https://youtrack.jetbrains.com/issue/KTIJ-21583/HMPP:-1.6.20-breaks-autocomplete-in-multiplatform-composite-buil#focus=Comments-27-6022244.0-0
Expand Down

0 comments on commit d940af8

Please sign in to comment.