mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 07:59:21 +08:00
Update dependencies + Kotlin 1.7 + KotlinPoet 1.12.0 (#1543)
This commit is contained in:
8
.github/workflows/build.yml
vendored
8
.github/workflows/build.yml
vendored
@@ -4,7 +4,7 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: 'Kotlin ${{ matrix.kotlin-version }} | Test Mode ${{ matrix.kotlin-test-mode }}'
|
name: 'Test Mode ${{ matrix.kotlin-test-mode }}'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Validate Gradle Wrapper
|
- name: Validate Gradle Wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v1
|
||||||
@@ -30,10 +30,10 @@ jobs:
|
|||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
- name: Configure JDK
|
- name: Configure JDK
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: '17'
|
java-version: '18'
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: ./gradlew build check --stacktrace -PkotlinTestMode=${{ matrix.kotlin-test-mode }}
|
run: ./gradlew build check --stacktrace -PkotlinTestMode=${{ matrix.kotlin-test-mode }}
|
||||||
|
@@ -48,17 +48,17 @@ spotless {
|
|||||||
java {
|
java {
|
||||||
configureCommonJavaFormat()
|
configureCommonJavaFormat()
|
||||||
target("**/*.java")
|
target("**/*.java")
|
||||||
targetExclude("**/build/**",)
|
targetExclude("**/build/**")
|
||||||
}
|
}
|
||||||
kotlin {
|
kotlin {
|
||||||
ktlint(libs.versions.ktlint.get()).userData(mapOf("indent_size" to "2"))
|
ktlint(libs.versions.ktlint.get()).editorConfigOverride(mapOf("indent_size" to "2"))
|
||||||
target("**/*.kt")
|
target("**/*.kt")
|
||||||
trimTrailingWhitespace()
|
trimTrailingWhitespace()
|
||||||
endWithNewline()
|
endWithNewline()
|
||||||
targetExclude("**/Dependencies.kt", "**/build/**")
|
targetExclude("**/Dependencies.kt", "**/build/**")
|
||||||
}
|
}
|
||||||
kotlinGradle {
|
kotlinGradle {
|
||||||
ktlint(libs.versions.ktlint.get()).userData(mapOf("indent_size" to "2"))
|
ktlint(libs.versions.ktlint.get()).editorConfigOverride(mapOf("indent_size" to "2"))
|
||||||
target("**/*.gradle.kts")
|
target("**/*.gradle.kts")
|
||||||
trimTrailingWhitespace()
|
trimTrailingWhitespace()
|
||||||
endWithNewline()
|
endWithNewline()
|
||||||
@@ -70,7 +70,7 @@ subprojects {
|
|||||||
pluginManager.withPlugin("java") {
|
pluginManager.withPlugin("java") {
|
||||||
configure<JavaPluginExtension> {
|
configure<JavaPluginExtension> {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(17))
|
languageVersion.set(JavaLanguageVersion.of(18))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (project.name != "records-tests") {
|
if (project.name != "records-tests") {
|
||||||
|
@@ -15,7 +15,7 @@ dependencies {
|
|||||||
tasks.withType<KotlinCompile>().configureEach {
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xopt-in=kotlin.ExperimentalStdlibApi"
|
"-opt-in=kotlin.ExperimentalStdlibApi"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,4 @@
|
|||||||
# Memory for Dokka https://github.com/Kotlin/dokka/issues/1405
|
# Memory for Dokka https://github.com/Kotlin/dokka/issues/1405
|
||||||
# --add-opens for GJF https://github.com/google/google-java-format#jdk-16
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 \
|
|
||||||
--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
|
||||||
--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
|
||||||
--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
|
||||||
--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
|
||||||
--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
|
||||||
|
|
||||||
kapt.include.compile.classpath=false
|
kapt.include.compile.classpath=false
|
||||||
|
@@ -1,37 +1,38 @@
|
|||||||
[versions]
|
[versions]
|
||||||
autoService = "1.0"
|
autoService = "1.0"
|
||||||
gjf = "1.11.0"
|
gjf = "1.15.0"
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
kotlin = "1.6.10"
|
kotlin = "1.7.0"
|
||||||
kotlinCompileTesting = "1.4.7"
|
kotlinCompileTesting = "1.4.9-alpha01"
|
||||||
kotlinpoet = "1.10.2"
|
kotlinpoet = "1.12.0"
|
||||||
ksp = "1.6.10-1.0.2"
|
ksp = "1.7.0-1.0.6"
|
||||||
ktlint = "0.41.0"
|
ktlint = "0.45.2"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" }
|
dokka = { id = "org.jetbrains.dokka", version = "1.6.21" }
|
||||||
japicmp = { id = "me.champeau.gradle.japicmp", version = "0.2.9" }
|
japicmp = { id = "me.champeau.gradle.japicmp", version = "0.2.9" }
|
||||||
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||||
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.18.0" }
|
mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.20.0" }
|
||||||
mavenShadow = { id = "com.github.johnrengelman.shadow", version = "7.0.0" }
|
mavenShadow = { id = "com.github.johnrengelman.shadow", version = "7.0.0" }
|
||||||
spotless = { id = "com.diffplug.spotless", version = "6.1.0" }
|
spotless = { id = "com.diffplug.spotless", version = "6.7.1" }
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
asm = "org.ow2.asm:asm:9.2"
|
asm = "org.ow2.asm:asm:9.3"
|
||||||
autoCommon = "com.google.auto:auto-common:1.1"
|
autoCommon = "com.google.auto:auto-common:1.1"
|
||||||
autoService = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" }
|
autoService = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" }
|
||||||
autoService-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.0.0"
|
autoService-ksp = "dev.zacsweers.autoservice:auto-service-ksp:1.0.0"
|
||||||
guava = "com.google.guava:guava:30.1.1-jre"
|
guava = "com.google.guava:guava:31.1-jre"
|
||||||
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
|
kotlin-annotationProcessingEmbeddable = { module = "org.jetbrains.kotlin:kotlin-annotation-processing-embeddable", version.ref = "kotlin" }
|
||||||
kotlin-compilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
|
kotlin-compilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" }
|
||||||
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
|
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
|
||||||
kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
|
kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "kotlinpoet" }
|
||||||
kotlinpoet-metadata = { module = "com.squareup:kotlinpoet-metadata", version.ref = "kotlinpoet" }
|
kotlinpoet-metadata = { module = "com.squareup:kotlinpoet-metadata", version.ref = "kotlinpoet" }
|
||||||
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", 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.4.2"
|
||||||
ksp = { module = "com.google.devtools.ksp:symbol-processing", version.ref = "ksp" }
|
ksp = { module = "com.google.devtools.ksp:symbol-processing", version.ref = "ksp" }
|
||||||
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
|
||||||
okio = "com.squareup.okio:okio:3.0.0"
|
okio = "com.squareup.okio:okio:3.1.0"
|
||||||
|
|
||||||
# Test libs
|
# Test libs
|
||||||
assertj = "org.assertj:assertj-core:3.11.1"
|
assertj = "org.assertj:assertj-core:3.11.1"
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@@ -16,10 +16,10 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
@Suppress("SuspiciousCollectionReassignment")
|
@Suppress("SuspiciousCollectionReassignment")
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xopt-in=kotlin.RequiresOptIn",
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
"-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview",
|
"-opt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview",
|
||||||
"-Xopt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview",
|
"-opt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview",
|
||||||
"-Xopt-in=com.squareup.moshi.kotlin.codegen.api.InternalMoshiCodegenApi",
|
"-opt-in=com.squareup.moshi.kotlin.codegen.api.InternalMoshiCodegenApi",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,6 @@ val shade: Configuration = configurations.maybeCreate("compileShaded")
|
|||||||
configurations.getByName("compileOnly").extendsFrom(shade)
|
configurations.getByName("compileOnly").extendsFrom(shade)
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":moshi"))
|
implementation(project(":moshi"))
|
||||||
implementation(kotlin("reflect"))
|
|
||||||
shade(libs.kotlinxMetadata) {
|
shade(libs.kotlinxMetadata) {
|
||||||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
||||||
}
|
}
|
||||||
@@ -54,10 +53,7 @@ dependencies {
|
|||||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
||||||
exclude(group = "com.google.guava")
|
exclude(group = "com.google.guava")
|
||||||
}
|
}
|
||||||
shade(libs.kotlinpoet.ksp) {
|
implementation(libs.kotlinpoet.ksp)
|
||||||
exclude(group = "org.jetbrains.kotlin")
|
|
||||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
|
||||||
}
|
|
||||||
implementation(libs.guava)
|
implementation(libs.guava)
|
||||||
implementation(libs.asm)
|
implementation(libs.asm)
|
||||||
|
|
||||||
@@ -72,6 +68,7 @@ dependencies {
|
|||||||
testImplementation(libs.ksp)
|
testImplementation(libs.ksp)
|
||||||
testImplementation(libs.ksp.api)
|
testImplementation(libs.ksp.api)
|
||||||
testImplementation(libs.kotlin.compilerEmbeddable)
|
testImplementation(libs.kotlin.compilerEmbeddable)
|
||||||
|
testImplementation(libs.kotlin.annotationProcessingEmbeddable)
|
||||||
testImplementation(libs.kotlinCompileTesting.ksp)
|
testImplementation(libs.kotlinCompileTesting.ksp)
|
||||||
|
|
||||||
// Copy these again as they're not automatically included since they're shaded
|
// Copy these again as they're not automatically included since they're shaded
|
||||||
|
@@ -184,7 +184,7 @@ public class AdapterGenerator(
|
|||||||
|
|
||||||
val generatedAdapter = generateType().let(typeHook)
|
val generatedAdapter = generateType().let(typeHook)
|
||||||
val result = FileSpec.builder(className.packageName, adapterName)
|
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.addAnnotation(COMMON_SUPPRESS)
|
||||||
result.addType(generatedAdapter)
|
result.addType(generatedAdapter)
|
||||||
val proguardConfig = if (generateProguardRules) {
|
val proguardConfig = if (generateProguardRules) {
|
||||||
|
@@ -42,7 +42,7 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||||||
allWarningsAsErrors = useWError
|
allWarningsAsErrors = useWError
|
||||||
@Suppress("SuspiciousCollectionReassignment")
|
@Suppress("SuspiciousCollectionReassignment")
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xopt-in=kotlin.ExperimentalStdlibApi"
|
"-opt-in=kotlin.ExperimentalStdlibApi"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ tasks.withType<KotlinCompile>().configureEach {
|
|||||||
allWarningsAsErrors = useWError
|
allWarningsAsErrors = useWError
|
||||||
@Suppress("SuspiciousCollectionReassignment")
|
@Suppress("SuspiciousCollectionReassignment")
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xopt-in=kotlin.ExperimentalStdlibApi"
|
"-opt-in=kotlin.ExperimentalStdlibApi"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -288,7 +288,7 @@ class KotlinJsonAdapterTest {
|
|||||||
} catch (expected: IllegalArgumentException) {
|
} catch (expected: IllegalArgumentException) {
|
||||||
assertThat(expected).hasMessageThat().isEqualTo(
|
assertThat(expected).hasMessageThat().isEqualTo(
|
||||||
"No default value for transient constructor parameter #0 " +
|
"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"
|
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ class KotlinJsonAdapterTest {
|
|||||||
} catch (expected: IllegalArgumentException) {
|
} catch (expected: IllegalArgumentException) {
|
||||||
assertThat(expected).hasMessageThat().isEqualTo(
|
assertThat(expected).hasMessageThat().isEqualTo(
|
||||||
"No default value for ignored constructor parameter #0 " +
|
"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"
|
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredIgnoredConstructorParameter"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -550,7 +550,7 @@ class KotlinJsonAdapterTest {
|
|||||||
fail()
|
fail()
|
||||||
} catch (expected: IllegalArgumentException) {
|
} catch (expected: IllegalArgumentException) {
|
||||||
assertThat(expected).hasMessageThat().isEqualTo(
|
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}"
|
"kotlin.Int, kotlin.Int): ${NonPropertyConstructorParameter::class.qualifiedName}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -61,12 +61,12 @@ tasks.withType<KotlinCompile>()
|
|||||||
.configureEach {
|
.configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
val toAdd = mutableListOf(
|
val toAdd = mutableListOf(
|
||||||
"-Xopt-in=kotlin.RequiresOptIn",
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
|
"-opt-in=kotlin.contracts.ExperimentalContracts",
|
||||||
"-Xjvm-default=enable"
|
"-Xjvm-default=all"
|
||||||
)
|
)
|
||||||
if (name.contains("test", true)) {
|
if (name.contains("test", true)) {
|
||||||
toAdd += "-Xopt-in=kotlin.ExperimentalStdlibApi"
|
toAdd += "-opt-in=kotlin.ExperimentalStdlibApi"
|
||||||
}
|
}
|
||||||
@Suppress("SuspiciousCollectionReassignment") // It's not suspicious
|
@Suppress("SuspiciousCollectionReassignment") // It's not suspicious
|
||||||
freeCompilerArgs += toAdd
|
freeCompilerArgs += toAdd
|
||||||
|
@@ -425,15 +425,15 @@ internal class JsonUtf8Reader : JsonReader {
|
|||||||
return when {
|
return when {
|
||||||
last == NUMBER_CHAR_DIGIT &&
|
last == NUMBER_CHAR_DIGIT &&
|
||||||
fitsInLong &&
|
fitsInLong &&
|
||||||
(value != Long.MIN_VALUE || negative)
|
(value != Long.MIN_VALUE || negative) &&
|
||||||
&& (value != 0L || !negative) -> {
|
(value != 0L || !negative) -> {
|
||||||
peekedLong = if (negative) value else -value
|
peekedLong = if (negative) value else -value
|
||||||
buffer.skip(i)
|
buffer.skip(i)
|
||||||
setPeeked(PEEKED_LONG)
|
setPeeked(PEEKED_LONG)
|
||||||
}
|
}
|
||||||
last == NUMBER_CHAR_DIGIT ||
|
last == NUMBER_CHAR_DIGIT ||
|
||||||
last == NUMBER_CHAR_FRACTION_DIGIT
|
last == NUMBER_CHAR_FRACTION_DIGIT ||
|
||||||
|| last == NUMBER_CHAR_EXP_DIGIT -> {
|
last == NUMBER_CHAR_EXP_DIGIT -> {
|
||||||
peekedNumberLength = i.toInt()
|
peekedNumberLength = i.toInt()
|
||||||
setPeeked(PEEKED_NUMBER)
|
setPeeked(PEEKED_NUMBER)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user