Update dependencies + Kotlin 1.7 + KotlinPoet 1.12.0 (#1543)

This commit is contained in:
Zac Sweers
2022-06-13 17:02:27 -04:00
committed by GitHub
parent 256d7b72aa
commit e95af32df8
13 changed files with 45 additions and 53 deletions

View File

@@ -4,7 +4,7 @@ on: [push, pull_request]
jobs:
build:
name: 'Kotlin ${{ matrix.kotlin-version }} | Test Mode ${{ matrix.kotlin-test-mode }}'
name: 'Test Mode ${{ matrix.kotlin-test-mode }}'
runs-on: ubuntu-latest
strategy:
@@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
@@ -30,10 +30,10 @@ jobs:
${{ runner.os }}-gradle-
- name: Configure JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-version: '18'
- name: Test
run: ./gradlew build check --stacktrace -PkotlinTestMode=${{ matrix.kotlin-test-mode }}

View File

@@ -48,17 +48,17 @@ spotless {
java {
configureCommonJavaFormat()
target("**/*.java")
targetExclude("**/build/**",)
targetExclude("**/build/**")
}
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")
trimTrailingWhitespace()
endWithNewline()
targetExclude("**/Dependencies.kt", "**/build/**")
}
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")
trimTrailingWhitespace()
endWithNewline()
@@ -70,7 +70,7 @@ subprojects {
pluginManager.withPlugin("java") {
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(18))
}
}
if (project.name != "records-tests") {

View File

@@ -15,7 +15,7 @@ dependencies {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}

View File

@@ -1,10 +1,4 @@
# 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 \
--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
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kapt.include.compile.classpath=false

View File

@@ -1,37 +1,38 @@
[versions]
autoService = "1.0"
gjf = "1.11.0"
gjf = "1.15.0"
jvmTarget = "1.8"
kotlin = "1.6.10"
kotlinCompileTesting = "1.4.7"
kotlinpoet = "1.10.2"
ksp = "1.6.10-1.0.2"
ktlint = "0.41.0"
kotlin = "1.7.0"
kotlinCompileTesting = "1.4.9-alpha01"
kotlinpoet = "1.12.0"
ksp = "1.7.0-1.0.6"
ktlint = "0.45.2"
[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" }
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" }
spotless = { id = "com.diffplug.spotless", version = "6.1.0" }
spotless = { id = "com.diffplug.spotless", version = "6.7.1" }
[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"
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"
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-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
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.4.2"
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:3.0.0"
okio = "com.squareup.okio:okio:3.1.0"
# Test libs
assertj = "org.assertj:assertj-core:3.11.1"

View File

@@ -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

View File

@@ -16,10 +16,10 @@ 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=kotlin.RequiresOptIn",
"-opt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview",
"-opt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview",
"-opt-in=com.squareup.moshi.kotlin.codegen.api.InternalMoshiCodegenApi",
)
}
}
@@ -44,7 +44,6 @@ val shade: Configuration = configurations.maybeCreate("compileShaded")
configurations.getByName("compileOnly").extendsFrom(shade)
dependencies {
implementation(project(":moshi"))
implementation(kotlin("reflect"))
shade(libs.kotlinxMetadata) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
@@ -54,10 +53,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)
@@ -72,6 +68,7 @@ dependencies {
testImplementation(libs.ksp)
testImplementation(libs.ksp.api)
testImplementation(libs.kotlin.compilerEmbeddable)
testImplementation(libs.kotlin.annotationProcessingEmbeddable)
testImplementation(libs.kotlinCompileTesting.ksp)
// Copy these again as they're not automatically included since they're shaded

View File

@@ -184,7 +184,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) {

View File

@@ -42,7 +42,7 @@ tasks.withType<KotlinCompile>().configureEach {
allWarningsAsErrors = useWError
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}

View File

@@ -43,7 +43,7 @@ tasks.withType<KotlinCompile>().configureEach {
allWarningsAsErrors = useWError
@Suppress("SuspiciousCollectionReassignment")
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}

View File

@@ -288,7 +288,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"
)
}
@@ -304,7 +304,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"
)
}
@@ -550,7 +550,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}"
)
}

View File

@@ -61,12 +61,12 @@ tasks.withType<KotlinCompile>()
.configureEach {
kotlinOptions {
val toAdd = mutableListOf(
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
"-Xjvm-default=enable"
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-Xjvm-default=all"
)
if (name.contains("test", true)) {
toAdd += "-Xopt-in=kotlin.ExperimentalStdlibApi"
toAdd += "-opt-in=kotlin.ExperimentalStdlibApi"
}
@Suppress("SuspiciousCollectionReassignment") // It's not suspicious
freeCompilerArgs += toAdd

View File

@@ -425,15 +425,15 @@ internal class JsonUtf8Reader : JsonReader {
return when {
last == NUMBER_CHAR_DIGIT &&
fitsInLong &&
(value != Long.MIN_VALUE || negative)
&& (value != 0L || !negative) -> {
(value != Long.MIN_VALUE || negative) &&
(value != 0L || !negative) -> {
peekedLong = if (negative) value else -value
buffer.skip(i)
setPeeked(PEEKED_LONG)
}
last == NUMBER_CHAR_DIGIT ||
last == NUMBER_CHAR_FRACTION_DIGIT
|| last == NUMBER_CHAR_EXP_DIGIT -> {
last == NUMBER_CHAR_FRACTION_DIGIT ||
last == NUMBER_CHAR_EXP_DIGIT -> {
peekedNumberLength = i.toInt()
setPeeked(PEEKED_NUMBER)
}