Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Kotlin to 2.1.0 #6291

Merged
merged 26 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions build-logic/src/main/kotlin/CompilerOptions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.ExternalDependency
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
Expand Down Expand Up @@ -29,6 +29,7 @@ fun KotlinCommonCompilerOptions.configure(target: Int, kotlinCompilerOptions: Ko
// D8 can dex Java17 bytecode
17
}

else -> target
}

Expand Down Expand Up @@ -67,7 +68,7 @@ fun KotlinCommonCompilerOptions.configure(target: Int, kotlinCompilerOptions: Ko
}

private fun Int.toJvmTarget(): JvmTarget {
return when(this) {
return when (this) {
8 -> JvmTarget.JVM_1_8
else -> JvmTarget.fromTarget(this.toString())
}
Expand Down Expand Up @@ -107,14 +108,20 @@ val Project.androidExtensionOrNull: BaseExtension?

fun Project.configureJavaAndKotlinCompilers(jvmTarget: Int?, kotlinCompilerOptions: KotlinCompilerOptions) {
@Suppress("NAME_SHADOWING")
val jvmTarget = jvmTarget?: 8
val jvmTarget = jvmTarget ?: 8

kotlinExtensionOrNull?.forEachCompilerOptions { isAndroid ->
configure(jvmTarget, kotlinCompilerOptions, isAndroid)
}
project.tasks.withType(JavaCompile::class.java).configureEach {
// For JVM only modules, this dictates the "org.gradle.jvm.version" Gradle attribute
options.release.set(jvmTarget)
if (androidExtensionOrNull == null) {
options.release.set(jvmTarget)
} else {
// Do not use options.release - see https://issuetracker.google.com/issues/278800528
sourceCompatibility = "$jvmTarget"
targetCompatibility = "$jvmTarget"
}
}
androidExtensionOrNull?.run {
compileOptions {
Expand All @@ -141,6 +148,7 @@ fun Project.configureJavaAndKotlinCompilers(jvmTarget: Int?, kotlinCompilerOptio
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

kotlinExtensionOrNull?.coreLibrariesVersion = "${kotlinCompilerOptions.version.version}.0"
/**
* Required because of:
*
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ org.gradle.parallel=true
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
org.jetbrains.dokka.gradle.enableLogHtmlPublicationLink=false

ksp.useKSP2=true
30 changes: 17 additions & 13 deletions gradle/libraries.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
# The version we use by default in tests and benchmarks
# Can be as high as IJ supports
# Consult https://kotlinlang.org/docs/multiplatform-compatibility-guide.html#version-compatibility for compatibility with KGP
android-plugin = "8.2.2"
# The version we compile against
android-plugin-min = "8.0.0"
Expand All @@ -27,13 +28,12 @@ javaPoet = "1.13.0"
jetbrains-annotations = "24.0.1"
junit = "4.13.2"
kotlin-plugin-min = "1.9.0"
kotlin-plugin = "2.0.20"
kotlin-plugin-max = "2.0.20"
kotlin-stdlib = "2.0.0"
kotlin-plugin = "2.1.0"
kotlin-plugin-max = "2.1.0"
kotlinx-coroutines = "1.9.0"
kotlinx-datetime = "0.5.0"
kotlinx-serialization-runtime = "1.6.2"
ksp = "2.0.20-1.0.24"
ksp = "2.1.0-1.0.29"
ktor = "3.0.0"
moshix = "0.14.1"
node-fetch = "2.6.7"
Expand Down Expand Up @@ -117,24 +117,28 @@ intellij-changelog = "org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.0
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
kotlin-allopen = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin-plugin" }
kotlin-compiletesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.4.0" }
kotlin-compiletesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.6.0" }
graphql-java = "com.graphql-java:graphql-java:20.4"
# The main kotlin version for build-logic and Gradle tests
kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin" }
kotlin-plugin-compose = { group = "org.jetbrains.kotlin", name = "compose-compiler-gradle-plugin", version.ref = "kotlin-plugin" }
# For Gradle integration tests to make sure we stay compatible with 1.5.0
kotlin-plugin-min = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin-min" }
kotlin-plugin-max = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin-max" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect" } # the Kotlin plugin resolves the version
kotlin-stdlib-common = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-common", version.ref = "kotlin-stdlib" }
kotlin-stdlib-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin-stdlib" }
kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin-stdlib" }
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin-stdlib" }
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" } # the Kotlin plugin resolves the version
kotlin-test-js = { group = "org.jetbrains.kotlin", name = "kotlin-test-js" } # the Kotlin plugin resolves the version
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" } # the Kotlin plugin resolves the version
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect" } # use same version as apiVersion
kotlin-stdlib-common = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-common" } # use same version as apiVersion
kotlin-stdlib-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib" } # use same version as apiVersion
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" } # use same version as apiVersion
kotlin-test-js = { group = "org.jetbrains.kotlin", name = "kotlin-test-js" } # use same version as apiVersion
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" } # use same version as apiVersion
# Kotlin/JS has no apiVersion:
# The Kotlin/JS standard library has an older version (2.0.20-release-360) than the compiler (2.1.0). Such a configuration is not supported.
# Please, make sure that the standard library has the version in the range [2.1.0 .. 2.1.255]. Adjust your project's settings if necessary.
kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin-plugin" }
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin-plugin" }
kotlinx-benchmark-runtime = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.8"
kotlinx-benchmark = "org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.12"
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.2"
androidx-benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha16"
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-rx2 = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-rx2", version.ref = "kotlinx-coroutines" }
Expand Down
2 changes: 2 additions & 0 deletions gradle/repositories.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ listOf(pluginManagement.repositories, dependencyResolutionManagement.repositorie
it.apply {
// Uncomment this one to use the Kotlin "dev" repository
// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
// Uncomment this one to use the Sonatype OSSRH snapshots repository
// maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }

mavenCentral()
exclusiveContent {
Expand Down
2 changes: 2 additions & 0 deletions intellij-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ commonSetup()
repositories {
// Uncomment this one to use the Kotlin "dev" repository
// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
// Uncomment this one to use the Sonatype OSSRH snapshots repository
// maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
mavenCentral()

intellijPlatform {
Expand Down
50 changes: 26 additions & 24 deletions kotlin-js-store-2.0/yarn.lock → kotlin-js-store-2.1/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ brace-expansion@^2.0.1:
balanced-match "^1.0.0"

braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
dependencies:
fill-range "^7.0.1"
fill-range "^7.1.1"

browser-stdout@^1.3.1:
version "1.3.1"
Expand Down Expand Up @@ -133,11 +133,11 @@ color-name@~1.1.4:
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

debug@^4.3.5:
version "4.3.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.6.tgz#2ab2c38fbaffebf8aa95fdfe6d88438c7a13c52b"
integrity sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==
version "4.3.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==
dependencies:
ms "2.1.2"
ms "^2.1.3"

decamelize@^4.0.0:
version "4.0.0"
Expand All @@ -155,9 +155,9 @@ emoji-regex@^8.0.0:
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==

escalade@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27"
integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==
version "3.2.0"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.2.0.tgz#011a3f69856ba189dffa7dc8fcce99d2a87903e5"
integrity sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==

escape-string-regexp@^4.0.0:
version "4.0.0"
Expand All @@ -169,10 +169,10 @@ event-target-shim@^5.0.0:
resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789"
integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==

fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==
dependencies:
to-regex-range "^5.0.1"

Expand Down Expand Up @@ -296,6 +296,13 @@ js-yaml@^4.1.0:
dependencies:
argparse "^2.0.1"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/kotlin-web-helpers/-/kotlin-web-helpers-2.0.0.tgz#b112096b273c1e733e0b86560998235c09a19286"
integrity sha512-xkVGl60Ygn/zuLkDPx+oHj7jeLR7hCvoNF99nhwXMn8a3ApB4lLiC9pk4ol4NHPjyoCbvQctBqvzUcp8pkqyWw==
dependencies:
format-util "^1.0.5"

locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
Expand All @@ -318,10 +325,10 @@ minimatch@^5.0.1, minimatch@^5.1.6:
dependencies:
brace-expansion "^2.0.1"

[email protected].0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.0.tgz#9e5cbed8fa9b37537a25bd1f7fb4f6fc45458b9a"
integrity sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==
[email protected].3:
version "10.7.3"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.7.3.tgz#ae32003cabbd52b59aece17846056a68eb4b0752"
integrity sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==
dependencies:
ansi-colors "^4.1.3"
browser-stdout "^1.3.1"
Expand All @@ -344,11 +351,6 @@ [email protected]:
yargs-parser "^20.2.9"
yargs-unparser "^2.0.0"

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

ms@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
Expand Down
7 changes: 0 additions & 7 deletions libraries/apollo-debug-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import org.jetbrains.dokka.gradle.tasks.DokkaGenerateTask
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("org.jetbrains.kotlin.multiplatform")
Expand All @@ -16,11 +14,6 @@ apolloLibrary(
withJs = false,
withWasm = false,
androidOptions = AndroidOptions(withCompose = false),
// Can't use apiVersion KOTLIN_2_0 when using languageVersion KOTLIN_1_9, which is the case here because we're using KSP 1
// TODO: move to KSP 2 and remove this when https://github.com/google/ksp/issues/1823 is resolved
kotlinCompilerOptions = KotlinCompilerOptions(
version = KotlinVersion.KOTLIN_1_9,
)
)

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.apollographql.apollo.api.ExecutionContext
import com.apollographql.apollo.ast.GQLValue
import com.apollographql.execution.Coercing
import com.apollographql.execution.ExecutableSchema
import com.apollographql.execution.ExternalValue
import com.apollographql.execution.StringCoercing
import com.apollographql.execution.annotation.GraphQLName
import com.apollographql.execution.annotation.GraphQLQuery
import com.apollographql.execution.annotation.GraphQLScalar
import com.apollographql.execution.ExternalValue
import com.apollographql.execution.parseAsGraphQLRequest
import kotlinx.coroutines.runBlocking
import okio.Buffer
Expand Down Expand Up @@ -49,12 +49,13 @@ internal class GraphQL(
* The root query
*/
@GraphQLQuery
internal class Query(private val apolloClients: AtomicReference<Map<ApolloClient, String>>) {
// Prefixing private fields with _ to work around https://github.com/google/ksp/issues/2135
martinbonnin marked this conversation as resolved.
Show resolved Hide resolved
internal class Query(private val _apolloClients: AtomicReference<Map<ApolloClient, String>>) {
private fun graphQLApolloClients() =
apolloClients.get().map { (apolloClient, apolloClientId) ->
_apolloClients.get().map { (apolloClient, apolloClientId) ->
GraphQLApolloClient(
id = apolloClientId,
apolloClient = apolloClient
_id = apolloClientId,
_apolloClient = apolloClient
)
}

Expand All @@ -72,17 +73,17 @@ internal class Query(private val apolloClients: AtomicReference<Map<ApolloClient

@GraphQLName("ApolloClient")
internal class GraphQLApolloClient(
private val id: String,
private val apolloClient: ApolloClient,
private val _id: String,
private val _apolloClient: ApolloClient,
) {
fun id(): ID = id
fun id(): ID = _id

fun displayName() = id
fun displayName() = _id

fun normalizedCaches(): List<NormalizedCache> {
val cacheDumpProvider = apolloClient.executionContext[CacheDumpProviderContext]?.cacheDumpProvider ?: return emptyList()
val cacheDumpProvider = _apolloClient.executionContext[CacheDumpProviderContext]?.cacheDumpProvider ?: return emptyList()
return cacheDumpProvider().map { (displayName, cacheDump) ->
NormalizedCache(apolloClientId = id, displayName = displayName, cacheDump = cacheDump)
NormalizedCache(apolloClientId = _id, _displayName = displayName, _cacheDump = cacheDump)
}
}

Expand All @@ -93,34 +94,34 @@ internal class GraphQLApolloClient(

internal class NormalizedCache(
apolloClientId: ID,
private val displayName: String,
private val cacheDump: CacheDump,
private val _displayName: String,
private val _cacheDump: CacheDump,
) {
private val id: String = "$apolloClientId:$displayName"
private val id: String = "$apolloClientId:$_displayName"
fun id(): ID = id

fun displayName() = displayName
fun displayName() = _displayName

fun recordCount() = cacheDump.count()
fun recordCount() = _cacheDump.count()

fun records(): List<GraphQLRecord> =
cacheDump.map { (key, record) -> GraphQLRecord(key = key, sizeInBytes = record.first, fields = record.second) }
_cacheDump.map { (key, record) -> GraphQLRecord(_key = key, _sizeInBytes = record.first, _fields = record.second) }
}

@GraphQLScalar(FieldsCoercing::class)
typealias Fields = Map<String, Any?>

@GraphQLName("Record")
internal class GraphQLRecord(
private val key: String,
private val sizeInBytes: Int,
private val fields: Fields,
private val _key: String,
private val _sizeInBytes: Int,
private val _fields: Fields,
) {
fun key(): String = key
fun key(): String = _key

fun fields(): Fields = fields
fun fields(): Fields = _fields

fun sizeInBytes(): Int = sizeInBytes
fun sizeInBytes(): Int = _sizeInBytes
}

internal object FieldsCoercing : Coercing<Fields> {
Expand Down
2 changes: 2 additions & 0 deletions libraries/apollo-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ tasks.withType<Test> {
addRelativeInput("testFiles", "testFiles")
addRelativeInput("testProjects", "testProjects")

maxHeapSize = "1g"

maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
}

Expand Down
Loading
Loading