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

Update dependencies + Kotlin 1.7 + KotlinPoet 1.12.0 #1543

Merged
merged 15 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += listOf(
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-opt-in=kotlin.ExperimentalStdlibApi"
)
}
}
8 changes: 1 addition & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
27 changes: 14 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
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
15 changes: 6 additions & 9 deletions moshi-kotlin-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
}
Expand All @@ -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")
}
Expand All @@ -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)

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion moshi-kotlin-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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 moshi-kotlin-tests/codegen-only/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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 @@ -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"
)
}
Expand All @@ -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"
)
}
Expand Down Expand Up @@ -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}"
)
}
Expand Down
8 changes: 4 additions & 4 deletions moshi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions moshi/src/main/java/com/squareup/moshi/JsonUtf8Reader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down