diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ec4f5f2f..614cefcb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,9 +23,9 @@ kotlin = "1.9.20" kotlinCompileTesting = "0.4.0-alpha01" kotlinpoet = "1.14.2" ksp = "1.9.20-1.0.13" -ktfmt = "0.44" +ktfmt = "0.46" moshi = "1.15.0" -okhttp = "4.11.0" +okhttp = "4.12.0" retrofit = "2.9.0" [plugins] @@ -35,7 +35,7 @@ kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } mavenPublish = { id = "com.vanniktech.maven.publish", version = "0.25.3" } mavenShadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } -moshix = { id = "dev.zacsweers.moshix", version = "0.24.2" } # Always replaced by the local plugin +moshix = { id = "dev.zacsweers.moshix", version = "0.24.3" } # Always replaced by the local plugin spotless = { id = "com.diffplug.spotless", version = "6.22.0" } [libraries] @@ -47,7 +47,7 @@ autoService = { module = "com.google.auto.service:auto-service-annotations", ver autoService-ksp = { module = "dev.zacsweers.autoservice:auto-service-ksp", version = "1.1.0" } autoService-processor = { module = "com.google.auto.service:auto-service", version.ref = "autoService" } -guava = { module = "com.google.guava:guava", version = "32.1.2-jre" } +guava = { module = "com.google.guava:guava", version = "32.1.3-jre" } incap = { module = "net.ltgt.gradle.incap:incap", version.ref = "incap" } incap-processor = { module = "net.ltgt.gradle.incap:incap-processor", version.ref = "incap" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ac72c34e..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/moshi-adapters/src/main/kotlin/dev/zacsweers/moshix/adapters/AdaptedBy.kt b/moshi-adapters/src/main/kotlin/dev/zacsweers/moshix/adapters/AdaptedBy.kt index 18032ce2..0dd70bdc 100644 --- a/moshi-adapters/src/main/kotlin/dev/zacsweers/moshix/adapters/AdaptedBy.kt +++ b/moshi-adapters/src/main/kotlin/dev/zacsweers/moshix/adapters/AdaptedBy.kt @@ -114,8 +114,7 @@ public annotation class AdaptedBy(val adapter: KClass<*>, val nullSafe: Boolean "value must be a JsonAdapter or JsonAdapter.Factory." ) } - } - ?: return null + } ?: return null return if (adaptedBy.nullSafe) { adapter.nullSafe() diff --git a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/MoshiIrUtil.kt b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/MoshiIrUtil.kt index 84a50704..a4323e5e 100644 --- a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/MoshiIrUtil.kt +++ b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/MoshiIrUtil.kt @@ -110,8 +110,7 @@ internal fun TargetProperty.generator( val qualifierRawType = jsonQualifier.type.classOrNull!!.owner val retentionValue = qualifierRawType.getAnnotation(FqName("kotlin.annotation.Retention"))?.getValueArgument(0) - as IrGetEnumValue? - ?: continue + as IrGetEnumValue? ?: continue // TODO what about java qualifiers types? val retention = retentionValue.symbol.owner.name.identifier // Check Java types since that covers both Java and Kotlin annotations. diff --git a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/sealed/SealedAdapterGenerator.kt b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/sealed/SealedAdapterGenerator.kt index cd716f97..dd8c7c13 100644 --- a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/sealed/SealedAdapterGenerator.kt +++ b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/sealed/SealedAdapterGenerator.kt @@ -481,8 +481,7 @@ private constructor( targetType = targetType.defaultType, moshiParam = moshiParam ) - } - ?: subtypesExpression + } ?: subtypesExpression // .create(Message::class.java, emptySet(), moshi) as JsonAdapter irExprBody( diff --git a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/IrSourcePrinter.kt b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/IrSourcePrinter.kt index 9a6fa113..77d1e80e 100644 --- a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/IrSourcePrinter.kt +++ b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/IrSourcePrinter.kt @@ -919,7 +919,8 @@ internal class IrSourcePrinterVisitor( print(": ") val type = declaration.backingField?.type - ?: declaration.getter?.returnType ?: error("Couldn't find return type") + ?: declaration.getter?.returnType + ?: error("Couldn't find return type") print(type.renderSrc()) declaration.backingField?.let { field -> field.initializer?.let { initializer -> diff --git a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/ir.kt b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/ir.kt index 009fd254..ffd74470 100644 --- a/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/ir.kt +++ b/moshi-ir/moshi-compiler-plugin/src/main/kotlin/dev/zacsweers/moshix/ir/compiler/util/ir.kt @@ -199,8 +199,9 @@ internal fun IrBuilderWithScope.defaultPrimitiveValue( internal val IrProperty.type: IrType get() = getter?.returnType - ?: setter?.valueParameters?.first()?.type ?: backingField?.type - ?: error("No type for property $name") + ?: setter?.valueParameters?.first()?.type + ?: backingField?.type + ?: error("No type for property $name") internal fun DescriptorVisibility.checkIsVisible() { if (this != DescriptorVisibilities.PUBLIC && this != DescriptorVisibilities.INTERNAL) { diff --git a/moshi-ir/moshi-gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/moshi-ir/moshi-gradle-plugin/gradle/wrapper/gradle-wrapper.properties index ac72c34e..3fa8f862 100644 --- a/moshi-ir/moshi-gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/moshi-ir/moshi-gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/moshi-ir/moshi-gradle-plugin/gradlew b/moshi-ir/moshi-gradle-plugin/gradlew index 0adc8e1a..1aa94a42 100755 --- a/moshi-ir/moshi-gradle-plugin/gradlew +++ b/moshi-ir/moshi-gradle-plugin/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/JvmDescriptors.kt b/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/JvmDescriptors.kt index 7ebc14cf..069d31aa 100644 --- a/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/JvmDescriptors.kt +++ b/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/JvmDescriptors.kt @@ -35,7 +35,8 @@ private val PRIMITIVE_CLASS_TO_DESC = internal val Class<*>.descriptor: String get() { return when { - isPrimitive -> PRIMITIVE_CLASS_TO_DESC[this]?.toString() + isPrimitive -> + PRIMITIVE_CLASS_TO_DESC[this]?.toString() ?: throw RuntimeException("Unrecognized primitive $this") isArray -> "[${componentType.descriptor}" else -> "L$name;".replace('.', '/') diff --git a/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/KtTypes.kt b/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/KtTypes.kt index 4d28bde3..d7874787 100644 --- a/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/KtTypes.kt +++ b/moshi-metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/reflect/KtTypes.kt @@ -217,8 +217,9 @@ internal data class KtProperty( val javaType = jvmField?.genericType - ?: jvmGetter?.genericReturnType ?: jvmSetter?.genericReturnType - ?: error( + ?: jvmGetter?.genericReturnType + ?: jvmSetter?.genericReturnType + ?: error( "No type information available for property '${km.name}' with type '${km.returnType.canonicalName}'." ) diff --git a/moshi-sealed/codegen/src/main/kotlin/dev/zacsweers/moshix/sealed/codegen/ksp/MoshiSealedSymbolProcessorProvider.kt b/moshi-sealed/codegen/src/main/kotlin/dev/zacsweers/moshix/sealed/codegen/ksp/MoshiSealedSymbolProcessorProvider.kt index d9f948b4..1e1615f6 100644 --- a/moshi-sealed/codegen/src/main/kotlin/dev/zacsweers/moshix/sealed/codegen/ksp/MoshiSealedSymbolProcessorProvider.kt +++ b/moshi-sealed/codegen/src/main/kotlin/dev/zacsweers/moshix/sealed/codegen/ksp/MoshiSealedSymbolProcessorProvider.kt @@ -414,7 +414,7 @@ private class MoshiSealedSymbolProcessor(environment: SymbolProcessorEnvironment val alternates = labelAnnotation.arguments.find { it.name?.getShortName() == "alternateLabels" }?.value as? List // arrays are lists in KSP https://github.com/google/ksp/issues/135 - ?: emptyList() // ksp ignores undefined args + ?: emptyList() // ksp ignores undefined args for (alternate in alternates) { seenLabels.put(alternate, className)?.let { prev -> diff --git a/moshi-sealed/metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MetadataMoshiSealedJsonAdapterFactory.kt b/moshi-sealed/metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MetadataMoshiSealedJsonAdapterFactory.kt index be98e046..d75231e9 100644 --- a/moshi-sealed/metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MetadataMoshiSealedJsonAdapterFactory.kt +++ b/moshi-sealed/metadata-reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MetadataMoshiSealedJsonAdapterFactory.kt @@ -64,8 +64,7 @@ public class MetadataMoshiSealedJsonAdapterFactory : JsonAdapter.Factory { val parentLabelKey = supertypes.firstNotNullOfOrNull { supertype -> supertype.getAnnotation(JsonClass::class.java)?.labelKey() - } - ?: error("No JsonClass-annotated sealed supertype found for $rawType") + } ?: error("No JsonClass-annotated sealed supertype found for $rawType") check(parentLabelKey != labelKey) { "@NestedSealed-annotated subtype $rawType is inappropriately annotated with @JsonClass(generator = \"sealed:$labelKey\")." } diff --git a/moshi-sealed/reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MoshiSealedJsonAdapterFactory.kt b/moshi-sealed/reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MoshiSealedJsonAdapterFactory.kt index f367e416..716930b9 100644 --- a/moshi-sealed/reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MoshiSealedJsonAdapterFactory.kt +++ b/moshi-sealed/reflect/src/main/kotlin/dev/zacsweers/moshix/sealed/reflect/MoshiSealedJsonAdapterFactory.kt @@ -58,8 +58,7 @@ public class MoshiSealedJsonAdapterFactory : JsonAdapter.Factory { (supertype.classifier as? KClass<*>)?.findAnnotation() ?: supertype.findAnnotation() nestedJsonClass?.labelKey() - } - ?: error("No JsonClass-annotated sealed supertype found for $rawTypeKotlin") + } ?: error("No JsonClass-annotated sealed supertype found for $rawTypeKotlin") check(parentLabelKey != labelKey) { "@NestedSealed-annotated subtype $rawType is inappropriately annotated with @JsonClass(generator = \"sealed:$labelKey\")." }