Skip to content

Commit

Permalink
Moshi 1.14.x updates (#1550)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ZacSweers authored Sep 6, 2022
1 parent 09a4543 commit 2b879c4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 23 deletions.
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
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" }
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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
11 changes: 3 additions & 8 deletions kotlin/codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ tasks.withType<KotlinCompile>().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",
)
}
}
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion kotlin/tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ tasks.withType<KotlinCompile>().configureEach {
allWarningsAsErrors = useWError
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion kotlin/tests/codegen-only/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tasks.withType<KotlinCompile>().configureEach {
allWarningsAsErrors = useWError
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class KotlinJsonAdapterTest {
} catch (expected: IllegalArgumentException) {
assertThat(expected).hasMessageThat().isEqualTo(
"No default value for transient constructor parameter #0 " +
"a of fun <init>(kotlin.Int): " +
"a of fun `<init>`(kotlin.Int): " +
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter"
)
}
Expand All @@ -305,7 +305,7 @@ class KotlinJsonAdapterTest {
} catch (expected: IllegalArgumentException) {
assertThat(expected).hasMessageThat().isEqualTo(
"No default value for ignored constructor parameter #0 " +
"a of fun <init>(kotlin.Int): " +
"a of fun `<init>`(kotlin.Int): " +
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredIgnoredConstructorParameter"
)
}
Expand Down Expand Up @@ -551,7 +551,7 @@ class KotlinJsonAdapterTest {
fail()
} catch (expected: IllegalArgumentException) {
assertThat(expected).hasMessageThat().isEqualTo(
"No property for required constructor parameter #0 a of fun <init>(" +
"No property for required constructor parameter #0 a of fun `<init>`(" +
"kotlin.Int, kotlin.Int): ${NonPropertyConstructorParameter::class.qualifiedName}"
)
}
Expand Down
2 changes: 1 addition & 1 deletion moshi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tasks.withType<KotlinCompile>()
kotlinOptions {
if (name.contains("test", true)) {
@Suppress("SuspiciousCollectionReassignment") // It's not suspicious
freeCompilerArgs += listOf("-Xopt-in=kotlin.ExperimentalStdlibApi")
freeCompilerArgs += listOf("-opt-in=kotlin.ExperimentalStdlibApi")
}
}
}
Expand Down

0 comments on commit 2b879c4

Please sign in to comment.