mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Modernize build a bit (#1383)
This commit is contained in:
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -40,7 +40,4 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish (default branch only)
|
- name: Publish (default branch only)
|
||||||
if: github.repository == 'square/moshi' && github.ref == 'refs/heads/master' && matrix.java-version == '16'
|
if: github.repository == 'square/moshi' && github.ref == 'refs/heads/master' && matrix.java-version == '16'
|
||||||
run: ./gradlew uploadArchives
|
run: ./gradlew publishToMavenCentral -PmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }} -PmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}
|
||||||
env:
|
|
||||||
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
|
|
||||||
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
|
|
||||||
|
@@ -20,10 +20,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(Dependencies.jsr305)
|
compileOnly(libs.jsr305)
|
||||||
api(project(":moshi"))
|
api(project(":moshi"))
|
||||||
|
|
||||||
testCompileOnly(Dependencies.jsr305)
|
testCompileOnly(libs.jsr305)
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ val baseline = configurations.create("baseline")
|
|||||||
val latest = configurations.create("latest")
|
val latest = configurations.create("latest")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
baseline("com.squareup.moshi:moshi-adapters:1.11.0") {
|
baseline("com.squareup.moshi:moshi-adapters:1.12.0") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
isForce = true
|
isForce = true
|
||||||
}
|
}
|
||||||
|
@@ -23,17 +23,17 @@ import java.net.URL
|
|||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath(kotlin("gradle-plugin", version = Dependencies.Kotlin.version))
|
classpath(kotlin("gradle-plugin", version = libs.versions.kotlin.get()))
|
||||||
// https://github.com/melix/japicmp-gradle-plugin/issues/36
|
// https://github.com/melix/japicmp-gradle-plugin/issues/36
|
||||||
classpath("com.google.guava:guava:28.2-jre")
|
classpath("com.google.guava:guava:28.2-jre")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.vanniktech.maven.publish") version "0.14.2" apply false
|
alias(libs.plugins.mavenPublish) apply false
|
||||||
id("org.jetbrains.dokka") version "1.4.32" apply false
|
alias(libs.plugins.dokka) apply false
|
||||||
id("com.diffplug.spotless") version "5.12.4"
|
alias(libs.plugins.spotless)
|
||||||
id("me.champeau.gradle.japicmp") version "0.2.9" apply false
|
alias(libs.plugins.japicmp) apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
spotless {
|
spotless {
|
||||||
@@ -67,7 +67,7 @@ spotless {
|
|||||||
"**/TypesTest.java"
|
"**/TypesTest.java"
|
||||||
)
|
)
|
||||||
val configureCommonJavaFormat: JavaExtension.() -> Unit = {
|
val configureCommonJavaFormat: JavaExtension.() -> Unit = {
|
||||||
googleJavaFormat("1.11.0")
|
googleJavaFormat(libs.versions.gjf.get())
|
||||||
}
|
}
|
||||||
java {
|
java {
|
||||||
configureCommonJavaFormat()
|
configureCommonJavaFormat()
|
||||||
@@ -86,7 +86,7 @@ spotless {
|
|||||||
target(*externalJavaFiles)
|
target(*externalJavaFiles)
|
||||||
}
|
}
|
||||||
kotlin {
|
kotlin {
|
||||||
ktlint(Dependencies.ktlintVersion).userData(mapOf("indent_size" to "2"))
|
ktlint(libs.versions.ktlint.get()).userData(mapOf("indent_size" to "2"))
|
||||||
target("**/*.kt")
|
target("**/*.kt")
|
||||||
trimTrailingWhitespace()
|
trimTrailingWhitespace()
|
||||||
endWithNewline()
|
endWithNewline()
|
||||||
@@ -95,7 +95,7 @@ spotless {
|
|||||||
targetExclude("**/Dependencies.kt", "**/spotless.kt", "**/build/**")
|
targetExclude("**/Dependencies.kt", "**/spotless.kt", "**/build/**")
|
||||||
}
|
}
|
||||||
kotlinGradle {
|
kotlinGradle {
|
||||||
ktlint(Dependencies.ktlintVersion).userData(mapOf("indent_size" to "2"))
|
ktlint(libs.versions.ktlint.get()).userData(mapOf("indent_size" to "2"))
|
||||||
target("**/*.gradle.kts")
|
target("**/*.gradle.kts")
|
||||||
trimTrailingWhitespace()
|
trimTrailingWhitespace()
|
||||||
endWithNewline()
|
endWithNewline()
|
||||||
@@ -106,20 +106,6 @@ spotless {
|
|||||||
subprojects {
|
subprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
// Required for Dokka
|
|
||||||
exclusiveContent {
|
|
||||||
forRepository {
|
|
||||||
maven {
|
|
||||||
name = "JCenter"
|
|
||||||
setUrl("https://jcenter.bintray.com/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filter {
|
|
||||||
includeModule("org.jetbrains.kotlinx", "kotlinx-html-jvm")
|
|
||||||
includeGroup("org.jetbrains.dokka")
|
|
||||||
includeModule("org.jetbrains", "markdown")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply with "java" instead of just "java-library" so kotlin projects get it too
|
// Apply with "java" instead of just "java-library" so kotlin projects get it too
|
||||||
@@ -141,7 +127,7 @@ subprojects {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
@Suppress("SuspiciousCollectionReassignment")
|
@Suppress("SuspiciousCollectionReassignment")
|
||||||
freeCompilerArgs += listOf("-progressive")
|
freeCompilerArgs += listOf("-progressive")
|
||||||
jvmTarget = "1.8"
|
jvmTarget = libs.versions.jvmTarget.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020 Square, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
`kotlin-dsl`
|
|
||||||
}
|
|
||||||
|
|
||||||
kotlinDslPluginOptions {
|
|
||||||
experimentalWarning.set(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2020 Square, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
object Dependencies {
|
|
||||||
|
|
||||||
const val asm = "org.ow2.asm:asm:7.1"
|
|
||||||
const val jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
|
||||||
const val ktlintVersion = "0.41.0"
|
|
||||||
const val okio = "com.squareup.okio:okio:2.10.0"
|
|
||||||
|
|
||||||
object AutoService {
|
|
||||||
private const val version = "1.0"
|
|
||||||
const val annotations = "com.google.auto.service:auto-service-annotations:$version"
|
|
||||||
const val processor = "com.google.auto.service:auto-service:$version"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Incap {
|
|
||||||
private const val version = "0.3"
|
|
||||||
const val annotations = "net.ltgt.gradle.incap:incap:$version"
|
|
||||||
const val processor = "net.ltgt.gradle.incap:incap-processor:$version"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Kotlin {
|
|
||||||
const val version = "1.5.0"
|
|
||||||
const val metadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.3.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
object KotlinPoet {
|
|
||||||
private const val version = "1.8.0"
|
|
||||||
const val kotlinPoet = "com.squareup:kotlinpoet:$version"
|
|
||||||
const val metadata = "com.squareup:kotlinpoet-metadata-specs:$version"
|
|
||||||
const val metadataSpecs = "com.squareup:kotlinpoet-metadata-specs:$version"
|
|
||||||
const val elementsClassInspector = "com.squareup:kotlinpoet-classinspector-elements:$version"
|
|
||||||
}
|
|
||||||
|
|
||||||
object Testing {
|
|
||||||
const val assertj = "org.assertj:assertj-core:3.11.1"
|
|
||||||
const val compileTesting = "com.github.tschuchortdev:kotlin-compile-testing:1.4.3"
|
|
||||||
const val junit = "junit:junit:4.13.2"
|
|
||||||
const val truth = "com.google.truth:truth:1.0.1"
|
|
||||||
}
|
|
||||||
}
|
|
@@ -21,7 +21,7 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
kapt(project(":kotlin:codegen"))
|
kapt(project(":kotlin:codegen"))
|
||||||
compileOnly(Dependencies.jsr305)
|
compileOnly(libs.jsr305)
|
||||||
implementation(project(":moshi"))
|
implementation(project(":moshi"))
|
||||||
implementation(project(":adapters"))
|
implementation(project(":adapters"))
|
||||||
}
|
}
|
||||||
|
53
gradle/libs.versions.toml
Normal file
53
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Copyright (C) 2021 Square, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
[versions]
|
||||||
|
autoService = "1.0"
|
||||||
|
gjf = "1.11.0"
|
||||||
|
incap = "0.3"
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
kotlin = "1.5.21"
|
||||||
|
kotlinCompileTesting = "1.4.3"
|
||||||
|
kotlinpoet = "1.9.0"
|
||||||
|
ktlint = "0.41.0"
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
dokka = { id = "org.jetbrains.dokka", version = "1.5.0" }
|
||||||
|
japicmp = { id = "me.champeau.gradle.japicmp", version = "0.2.9" }
|
||||||
|
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"
|
||||||
|
autoCommon = "com.google.auto:auto-common:1.1"
|
||||||
|
autoService = { module = "com.google.auto.service:auto-service-annotations", version.ref = "autoService" }
|
||||||
|
autoService-processor = { module = "com.google.auto.service:auto-service", version.ref = "autoService" }
|
||||||
|
incap = { module = "net.ltgt.gradle.incap:incap", version.ref = "incap" }
|
||||||
|
incap-processor = { module = "net.ltgt.gradle.incap:incap-processor", version.ref = "incap" }
|
||||||
|
jsr305 = "com.google.code.findbugs:jsr305:3.0.2"
|
||||||
|
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-elementsClassInspector = { module = "com.squareup:kotlinpoet-classinspector-elements", version.ref = "kotlinpoet" }
|
||||||
|
kotlinpoet-metadata-core = { module = "com.squareup:kotlinpoet-metadata", version.ref = "kotlinpoet" }
|
||||||
|
kotlinpoet-metadata-specs = { module = "com.squareup:kotlinpoet-metadata-specs", version.ref = "kotlinpoet" }
|
||||||
|
kotlinxMetadata = "org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.3.0"
|
||||||
|
okio = "com.squareup.okio:okio:2.10.0"
|
||||||
|
|
||||||
|
# Test libs
|
||||||
|
assertj = "org.assertj:assertj-core:3.11.1"
|
||||||
|
junit = "junit:junit:4.13.2"
|
||||||
|
kotlinCompileTesting = { module = "com.github.tschuchortdev:kotlin-compile-testing", version.ref = "kotlinCompileTesting" }
|
||||||
|
truth = "com.google.truth:truth:1.1.3"
|
@@ -22,14 +22,15 @@ plugins {
|
|||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
kotlin("kapt")
|
kotlin("kapt")
|
||||||
id("com.vanniktech.maven.publish")
|
id("com.vanniktech.maven.publish")
|
||||||
id("com.github.johnrengelman.shadow") version "7.0.0"
|
alias(libs.plugins.mavenShadow)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
@Suppress("SuspiciousCollectionReassignment")
|
@Suppress("SuspiciousCollectionReassignment")
|
||||||
freeCompilerArgs += listOf(
|
freeCompilerArgs += listOf(
|
||||||
"-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview"
|
"-Xopt-in=kotlin.RequiresOptIn",
|
||||||
|
"-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,38 +58,38 @@ dependencies {
|
|||||||
// https://youtrack.jetbrains.com/issue/KT-41702
|
// https://youtrack.jetbrains.com/issue/KT-41702
|
||||||
api(project(":moshi"))
|
api(project(":moshi"))
|
||||||
api(kotlin("reflect"))
|
api(kotlin("reflect"))
|
||||||
shade(Dependencies.Kotlin.metadata) {
|
shade(libs.kotlinxMetadata) {
|
||||||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
||||||
}
|
}
|
||||||
api(Dependencies.KotlinPoet.kotlinPoet)
|
api(libs.kotlinpoet)
|
||||||
shade(Dependencies.KotlinPoet.metadata) {
|
shade(libs.kotlinpoet.metadata.core) {
|
||||||
exclude(group = "org.jetbrains.kotlin")
|
exclude(group = "org.jetbrains.kotlin")
|
||||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
||||||
}
|
}
|
||||||
shade(Dependencies.KotlinPoet.metadataSpecs) {
|
shade(libs.kotlinpoet.metadata.specs) {
|
||||||
exclude(group = "org.jetbrains.kotlin")
|
exclude(group = "org.jetbrains.kotlin")
|
||||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
||||||
}
|
}
|
||||||
api(Dependencies.KotlinPoet.elementsClassInspector)
|
api(libs.kotlinpoet.elementsClassInspector)
|
||||||
shade(Dependencies.KotlinPoet.elementsClassInspector) {
|
shade(libs.kotlinpoet.elementsClassInspector) {
|
||||||
exclude(group = "org.jetbrains.kotlin")
|
exclude(group = "org.jetbrains.kotlin")
|
||||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
||||||
exclude(group = "com.google.guava")
|
exclude(group = "com.google.guava")
|
||||||
}
|
}
|
||||||
api(Dependencies.asm)
|
api(libs.asm)
|
||||||
|
|
||||||
api(Dependencies.AutoService.annotations)
|
api(libs.autoService)
|
||||||
kapt(Dependencies.AutoService.processor)
|
kapt(libs.autoService.processor)
|
||||||
api(Dependencies.Incap.annotations)
|
api(libs.incap)
|
||||||
kapt(Dependencies.Incap.processor)
|
kapt(libs.incap.processor)
|
||||||
|
|
||||||
// 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
|
||||||
testImplementation(Dependencies.KotlinPoet.metadata)
|
testImplementation(libs.kotlinpoet.metadata.core)
|
||||||
testImplementation(Dependencies.KotlinPoet.metadataSpecs)
|
testImplementation(libs.kotlinpoet.metadata.specs)
|
||||||
testImplementation(Dependencies.KotlinPoet.elementsClassInspector)
|
testImplementation(libs.kotlinpoet.elementsClassInspector)
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
testImplementation(Dependencies.Testing.compileTesting)
|
testImplementation(libs.kotlinCompileTesting)
|
||||||
}
|
}
|
||||||
|
|
||||||
val relocateShadowJar = tasks.register<ConfigureShadowRelocation>("relocateShadowJar") {
|
val relocateShadowJar = tasks.register<ConfigureShadowRelocation>("relocateShadowJar") {
|
||||||
|
@@ -85,7 +85,10 @@ internal class AdapterGenerator(
|
|||||||
// KotlinPoet always generates explicit public modifiers for public members.
|
// KotlinPoet always generates explicit public modifiers for public members.
|
||||||
"RedundantVisibilityModifier",
|
"RedundantVisibilityModifier",
|
||||||
// For LambdaTypeNames we have to import kotlin.functions.* types
|
// For LambdaTypeNames we have to import kotlin.functions.* types
|
||||||
"PLATFORM_CLASS_MAPPED_TO_KOTLIN"
|
"PLATFORM_CLASS_MAPPED_TO_KOTLIN",
|
||||||
|
// Cover for calling fromJson() on a Nothing property type. Theoretically nonsensical but we
|
||||||
|
// support it
|
||||||
|
"IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION"
|
||||||
).let { suppressions ->
|
).let { suppressions ->
|
||||||
AnnotationSpec.builder(Suppress::class)
|
AnnotationSpec.builder(Suppress::class)
|
||||||
.useSiteTarget(FILE)
|
.useSiteTarget(FILE)
|
||||||
|
@@ -23,6 +23,7 @@ import com.squareup.kotlinpoet.CHAR
|
|||||||
import com.squareup.kotlinpoet.ClassName
|
import com.squareup.kotlinpoet.ClassName
|
||||||
import com.squareup.kotlinpoet.CodeBlock
|
import com.squareup.kotlinpoet.CodeBlock
|
||||||
import com.squareup.kotlinpoet.DOUBLE
|
import com.squareup.kotlinpoet.DOUBLE
|
||||||
|
import com.squareup.kotlinpoet.DelicateKotlinPoetApi
|
||||||
import com.squareup.kotlinpoet.FLOAT
|
import com.squareup.kotlinpoet.FLOAT
|
||||||
import com.squareup.kotlinpoet.INT
|
import com.squareup.kotlinpoet.INT
|
||||||
import com.squareup.kotlinpoet.KModifier
|
import com.squareup.kotlinpoet.KModifier
|
||||||
@@ -79,6 +80,7 @@ internal fun TypeName.defaultPrimitiveValue(): CodeBlock =
|
|||||||
else -> CodeBlock.of("null")
|
else -> CodeBlock.of("null")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(DelicateKotlinPoetApi::class)
|
||||||
internal fun TypeName.asTypeBlock(): CodeBlock {
|
internal fun TypeName.asTypeBlock(): CodeBlock {
|
||||||
if (annotations.isNotEmpty()) {
|
if (annotations.isNotEmpty()) {
|
||||||
return copy(annotations = emptyList()).asTypeBlock()
|
return copy(annotations = emptyList()).asTypeBlock()
|
||||||
|
@@ -17,6 +17,7 @@ package com.squareup.moshi.kotlin.codegen
|
|||||||
|
|
||||||
import com.squareup.kotlinpoet.AnnotationSpec
|
import com.squareup.kotlinpoet.AnnotationSpec
|
||||||
import com.squareup.kotlinpoet.ClassName
|
import com.squareup.kotlinpoet.ClassName
|
||||||
|
import com.squareup.kotlinpoet.DelicateKotlinPoetApi
|
||||||
import com.squareup.kotlinpoet.KModifier
|
import com.squareup.kotlinpoet.KModifier
|
||||||
import com.squareup.kotlinpoet.LambdaTypeName
|
import com.squareup.kotlinpoet.LambdaTypeName
|
||||||
import com.squareup.kotlinpoet.ParameterizedTypeName
|
import com.squareup.kotlinpoet.ParameterizedTypeName
|
||||||
@@ -117,6 +118,7 @@ internal fun primaryConstructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a target type for `element`, or null if it cannot be used with code gen. */
|
/** Returns a target type for `element`, or null if it cannot be used with code gen. */
|
||||||
|
@OptIn(DelicateKotlinPoetApi::class)
|
||||||
@KotlinPoetMetadataPreview
|
@KotlinPoetMetadataPreview
|
||||||
internal fun targetType(
|
internal fun targetType(
|
||||||
messager: Messager,
|
messager: Messager,
|
||||||
@@ -233,7 +235,6 @@ internal fun targetType(
|
|||||||
val resolvedTypes = mutableListOf<ResolvedTypeMapping>()
|
val resolvedTypes = mutableListOf<ResolvedTypeMapping>()
|
||||||
val superTypes = appliedType.supertypes(types)
|
val superTypes = appliedType.supertypes(types)
|
||||||
.filterNot { supertype ->
|
.filterNot { supertype ->
|
||||||
@Suppress("DEPRECATION") // Appropriate in this case
|
|
||||||
supertype.element.asClassName() == OBJECT_CLASS || // Don't load properties for java.lang.Object.
|
supertype.element.asClassName() == OBJECT_CLASS || // Don't load properties for java.lang.Object.
|
||||||
supertype.element.kind != ElementKind.CLASS // Don't load properties for interface types.
|
supertype.element.kind != ElementKind.CLASS // Don't load properties for interface types.
|
||||||
}
|
}
|
||||||
@@ -273,7 +274,6 @@ internal fun targetType(
|
|||||||
val superSuperClass = supertype.element.superclass as DeclaredType
|
val superSuperClass = supertype.element.superclass as DeclaredType
|
||||||
|
|
||||||
// Convert to an element and back to wipe the typed generics off of this
|
// Convert to an element and back to wipe the typed generics off of this
|
||||||
@Suppress("DEPRECATION") // Appropriate in this case
|
|
||||||
val untyped = superSuperClass.asElement().asType().asTypeName() as ParameterizedTypeName
|
val untyped = superSuperClass.asElement().asType().asTypeName() as ParameterizedTypeName
|
||||||
resolvedTypes += ResolvedTypeMapping(
|
resolvedTypes += ResolvedTypeMapping(
|
||||||
target = untyped.rawType,
|
target = untyped.rawType,
|
||||||
@@ -289,7 +289,6 @@ internal fun targetType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for ((localAppliedType, supertypeApi) in superTypes.entries) {
|
for ((localAppliedType, supertypeApi) in superTypes.entries) {
|
||||||
@Suppress("DEPRECATION") // Appropriate in this case
|
|
||||||
val appliedClassName = localAppliedType.element.asClassName()
|
val appliedClassName = localAppliedType.element.asClassName()
|
||||||
val supertypeProperties = declaredProperties(
|
val supertypeProperties = declaredProperties(
|
||||||
constructor = constructor,
|
constructor = constructor,
|
||||||
@@ -317,7 +316,6 @@ internal fun targetType(
|
|||||||
if (forceInternal) KModifier.INTERNAL else visibility
|
if (forceInternal) KModifier.INTERNAL else visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION") // Appropriate in this case
|
|
||||||
return TargetType(
|
return TargetType(
|
||||||
typeName = element.asType().asTypeName(),
|
typeName = element.asType().asTypeName(),
|
||||||
constructor = constructor,
|
constructor = constructor,
|
||||||
|
@@ -24,6 +24,6 @@ dependencies {
|
|||||||
api(kotlin("reflect"))
|
api(kotlin("reflect"))
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ dependencies {
|
|||||||
testImplementation(project(":moshi"))
|
testImplementation(project(":moshi"))
|
||||||
testImplementation(project(":kotlin:reflect"))
|
testImplementation(project(":kotlin:reflect"))
|
||||||
testImplementation(kotlin("reflect"))
|
testImplementation(kotlin("reflect"))
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.assertj)
|
testImplementation(libs.assertj)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
}
|
}
|
||||||
|
@@ -72,10 +72,10 @@ tasks.withType<KotlinCompile>()
|
|||||||
dependencies {
|
dependencies {
|
||||||
// So the j16 source set can "see" main Moshi sources
|
// So the j16 source set can "see" main Moshi sources
|
||||||
"java16Implementation"(mainSourceSet.output)
|
"java16Implementation"(mainSourceSet.output)
|
||||||
compileOnly(Dependencies.jsr305)
|
compileOnly(libs.jsr305)
|
||||||
api(Dependencies.okio)
|
api(libs.okio)
|
||||||
|
|
||||||
testCompileOnly(Dependencies.jsr305)
|
testCompileOnly(libs.jsr305)
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ val baseline = configurations.create("baseline")
|
|||||||
val latest = configurations.create("latest")
|
val latest = configurations.create("latest")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
baseline("com.squareup.moshi:moshi:1.11.0") {
|
baseline("com.squareup.moshi:moshi:1.12.0") {
|
||||||
isTransitive = false
|
isTransitive = false
|
||||||
isForce = true
|
isForce = true
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ tasks.withType<JavaCompile>().configureEach {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(project(":moshi"))
|
testImplementation(project(":moshi"))
|
||||||
testCompileOnly(Dependencies.jsr305)
|
testCompileOnly(libs.jsr305)
|
||||||
testImplementation(Dependencies.Testing.junit)
|
testImplementation(libs.junit)
|
||||||
testImplementation(Dependencies.Testing.truth)
|
testImplementation(libs.truth)
|
||||||
}
|
}
|
||||||
|
@@ -31,3 +31,5 @@ include(":examples")
|
|||||||
include(":kotlin:reflect")
|
include(":kotlin:reflect")
|
||||||
include(":kotlin:codegen")
|
include(":kotlin:codegen")
|
||||||
include(":kotlin:tests")
|
include(":kotlin:tests")
|
||||||
|
|
||||||
|
enableFeaturePreview("VERSION_CATALOGS")
|
||||||
|
Reference in New Issue
Block a user