From 2b879c4441f360ebfde28eb711d7fa05ff9cfc78 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Tue, 6 Sep 2022 10:38:06 -0400 Subject: [PATCH] Moshi 1.14.x updates (#1550) * Update dependencies to 1.7 + KP 1.13 * Update gradle to 7.4.2 * Update file comment API * Unshade kotlinpoet KSP * Update other -Xopt-in markers * Update KP refs --- gradle/libs.versions.toml | 14 +++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- kotlin/codegen/build.gradle.kts | 11 +++-------- .../moshi/kotlin/codegen/api/AdapterGenerator.kt | 2 +- kotlin/tests/build.gradle.kts | 2 +- kotlin/tests/codegen-only/build.gradle.kts | 2 +- .../moshi/kotlin/reflect/KotlinJsonAdapterTest.kt | 6 +++--- moshi/build.gradle.kts | 2 +- 8 files changed, 18 insertions(+), 23 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 798eb9fe7..a37f95cb9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,14 +16,14 @@ autoService = "1.0" gjf = "1.11.0" jvmTarget = "1.8" -kotlin = "1.6.0" -kotlinCompileTesting = "1.4.6" -kotlinpoet = "1.10.2" -ksp = "1.6.0-1.0.1" +kotlin = "1.7.0" +kotlinCompileTesting = "1.4.9" +kotlinpoet = "1.12.0" +ksp = "1.7.0-1.0.6" ktlint = "0.41.0" [plugins] -dokka = { id = "org.jetbrains.dokka", version = "1.5.31" } +dokka = { id = "org.jetbrains.dokka", version = "1.7.0" } japicmp = { id = "me.champeau.gradle.japicmp", version = "0.2.9" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.17.0" } @@ -31,7 +31,7 @@ mavenShadow = { id = "com.github.johnrengelman.shadow", version = "7.0.0" } spotless = { id = "com.diffplug.spotless", version = "5.14.2" } [libraries] -asm = "org.ow2.asm:asm:9.2" +asm = "org.ow2.asm:asm:9.3" autoCommon = "com.google.auto:auto-common:1.1" autoService = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" } autoService-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.0.0" @@ -42,7 +42,7 @@ kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" } kotlinpoet-metadata = { module = "com.squareup:kotlinpoet-metadata", version.ref = "kotlinpoet" } kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlinpoet" } -kotlinxMetadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.4.0" +kotlinxMetadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0" ksp = { module = "com.google.devtools.ksp:symbol-processing", version.ref = "ksp" } ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" } okio = "com.squareup.okio:okio:2.10.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e0..aa991fcea 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/kotlin/codegen/build.gradle.kts b/kotlin/codegen/build.gradle.kts index c446af6b2..fcace6116 100644 --- a/kotlin/codegen/build.gradle.kts +++ b/kotlin/codegen/build.gradle.kts @@ -29,10 +29,8 @@ tasks.withType().configureEach { kotlinOptions { @Suppress("SuspiciousCollectionReassignment") freeCompilerArgs += listOf( - "-Xopt-in=kotlin.RequiresOptIn", - "-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview", - "-Xopt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview", - "-Xopt-in=com.squareup.moshi.kotlin.codegen.api.InternalMoshiCodegenApi", + "-opt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview", + "-opt-in=com.squareup.moshi.kotlin.codegen.api.InternalMoshiCodegenApi", ) } } @@ -67,10 +65,7 @@ dependencies { exclude(group = "com.squareup", module = "kotlinpoet") exclude(group = "com.google.guava") } - shade(libs.kotlinpoet.ksp) { - exclude(group = "org.jetbrains.kotlin") - exclude(group = "com.squareup", module = "kotlinpoet") - } + implementation(libs.kotlinpoet.ksp) implementation(libs.guava) implementation(libs.asm) diff --git a/kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/AdapterGenerator.kt b/kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/AdapterGenerator.kt index 9878ce672..1c0857e71 100644 --- a/kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/AdapterGenerator.kt +++ b/kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/AdapterGenerator.kt @@ -182,7 +182,7 @@ public class AdapterGenerator( val generatedAdapter = generateType().let(typeHook) val result = FileSpec.builder(className.packageName, adapterName) - result.addComment("Code generated by moshi-kotlin-codegen. Do not edit.") + result.addFileComment("Code generated by moshi-kotlin-codegen. Do not edit.") result.addAnnotation(COMMON_SUPPRESS) result.addType(generatedAdapter) val proguardConfig = if (generateProguardRules) { diff --git a/kotlin/tests/build.gradle.kts b/kotlin/tests/build.gradle.kts index e4e9fba6a..f9705faf5 100644 --- a/kotlin/tests/build.gradle.kts +++ b/kotlin/tests/build.gradle.kts @@ -58,7 +58,7 @@ tasks.withType().configureEach { allWarningsAsErrors = useWError @Suppress("SuspiciousCollectionReassignment") freeCompilerArgs += listOf( - "-Xopt-in=kotlin.ExperimentalStdlibApi" + "-opt-in=kotlin.ExperimentalStdlibApi" ) } } diff --git a/kotlin/tests/codegen-only/build.gradle.kts b/kotlin/tests/codegen-only/build.gradle.kts index 7c5acb26a..d6f993c04 100644 --- a/kotlin/tests/codegen-only/build.gradle.kts +++ b/kotlin/tests/codegen-only/build.gradle.kts @@ -59,7 +59,7 @@ tasks.withType().configureEach { allWarningsAsErrors = useWError @Suppress("SuspiciousCollectionReassignment") freeCompilerArgs += listOf( - "-Xopt-in=kotlin.ExperimentalStdlibApi" + "-opt-in=kotlin.ExperimentalStdlibApi" ) } } diff --git a/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt b/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt index 295a61c96..b54f4f998 100644 --- a/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt +++ b/kotlin/tests/src/test/kotlin/com/squareup/moshi/kotlin/reflect/KotlinJsonAdapterTest.kt @@ -289,7 +289,7 @@ class KotlinJsonAdapterTest { } catch (expected: IllegalArgumentException) { assertThat(expected).hasMessageThat().isEqualTo( "No default value for transient constructor parameter #0 " + - "a of fun (kotlin.Int): " + + "a of fun ``(kotlin.Int): " + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter" ) } @@ -305,7 +305,7 @@ class KotlinJsonAdapterTest { } catch (expected: IllegalArgumentException) { assertThat(expected).hasMessageThat().isEqualTo( "No default value for ignored constructor parameter #0 " + - "a of fun (kotlin.Int): " + + "a of fun ``(kotlin.Int): " + "com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredIgnoredConstructorParameter" ) } @@ -551,7 +551,7 @@ class KotlinJsonAdapterTest { fail() } catch (expected: IllegalArgumentException) { assertThat(expected).hasMessageThat().isEqualTo( - "No property for required constructor parameter #0 a of fun (" + + "No property for required constructor parameter #0 a of fun ``(" + "kotlin.Int, kotlin.Int): ${NonPropertyConstructorParameter::class.qualifiedName}" ) } diff --git a/moshi/build.gradle.kts b/moshi/build.gradle.kts index a89e79b5e..f31e64267 100644 --- a/moshi/build.gradle.kts +++ b/moshi/build.gradle.kts @@ -65,7 +65,7 @@ tasks.withType() kotlinOptions { if (name.contains("test", true)) { @Suppress("SuspiciousCollectionReassignment") // It's not suspicious - freeCompilerArgs += listOf("-Xopt-in=kotlin.ExperimentalStdlibApi") + freeCompilerArgs += listOf("-opt-in=kotlin.ExperimentalStdlibApi") } } }