mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
* Standardize around JDK 8 * Update GJF to support newer JDKs * Fix misc java 8 issues in tests * Prepare java 16/records checking at runtime * Implement real RecordJsonAdapter * Spotless * Prepare build for JDK 16+ * Fix property name for kapt * Small cleanup * Make FallbackEnum java-8 happy * Remove animalsniffer * Fix format * Add opens for ExtendsPlatformClassWithProtectedFields * Return null every time in shim for main tests * Use JDK 16 + release 8 to replace animalsniffer * Simplify accessor accessible handling * Remove manifest attrs * Fix typo * Fix KCT tests + upgrade it * Cover another * Try explicit kotlin daemon args for java 17? * Disable 17-ea for now until kotlin 1.5.30 * Add JsonQualifier and Json(name) tests + fix qualifiers * Ensure constructor is accessible * GJF it properly * GJF 1.11 * Unwrap InvocationTargetException * Use MethodHandle for constructor * Use MethodHandle for accessor too * Revert "Remove manifest attrs" This reverts commit 3eb768fd6904bb5c979aa01c3c182e0fb9329d62. * Proper MR jar * *actually* fix GJF, which wasn't getting applied before We can just enable this everywhere now since we require JDK 16 anyway * Make IDE happy about modules access * Fixup records tests to play nice with modules Gotta be public * Add complex smoke test * Remove comment Not a regression test in this case
117 lines
4.3 KiB
Plaintext
117 lines
4.3 KiB
Plaintext
/*
|
|
* 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.
|
|
*/
|
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
|
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
|
|
plugins {
|
|
kotlin("jvm")
|
|
kotlin("kapt")
|
|
id("com.vanniktech.maven.publish")
|
|
id("com.github.johnrengelman.shadow") version "7.0.0"
|
|
}
|
|
|
|
tasks.withType<KotlinCompile>().configureEach {
|
|
kotlinOptions {
|
|
@Suppress("SuspiciousCollectionReassignment")
|
|
freeCompilerArgs += listOf(
|
|
"-Xopt-in=com.squareup.kotlinpoet.metadata.KotlinPoetMetadataPreview"
|
|
)
|
|
}
|
|
}
|
|
|
|
tasks.withType<Test>().configureEach {
|
|
// For kapt to work with kotlin-compile-testing
|
|
jvmArgs(
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
|
"--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
|
)
|
|
}
|
|
|
|
val shade: Configuration = configurations.maybeCreate("compileShaded")
|
|
configurations.getByName("compileOnly").extendsFrom(shade)
|
|
dependencies {
|
|
// Use `api` because kapt will not resolve `runtime` dependencies without it, only `compile`
|
|
// https://youtrack.jetbrains.com/issue/KT-41702
|
|
api(project(":moshi"))
|
|
api(kotlin("reflect"))
|
|
shade(Dependencies.Kotlin.metadata) {
|
|
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
|
}
|
|
api(Dependencies.KotlinPoet.kotlinPoet)
|
|
shade(Dependencies.KotlinPoet.metadata) {
|
|
exclude(group = "org.jetbrains.kotlin")
|
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
|
}
|
|
shade(Dependencies.KotlinPoet.metadataSpecs) {
|
|
exclude(group = "org.jetbrains.kotlin")
|
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
|
}
|
|
api(Dependencies.KotlinPoet.elementsClassInspector)
|
|
shade(Dependencies.KotlinPoet.elementsClassInspector) {
|
|
exclude(group = "org.jetbrains.kotlin")
|
|
exclude(group = "com.squareup", module = "kotlinpoet")
|
|
exclude(group = "com.google.guava")
|
|
}
|
|
api(Dependencies.asm)
|
|
|
|
api(Dependencies.AutoService.annotations)
|
|
kapt(Dependencies.AutoService.processor)
|
|
api(Dependencies.Incap.annotations)
|
|
kapt(Dependencies.Incap.processor)
|
|
|
|
// Copy these again as they're not automatically included since they're shaded
|
|
testImplementation(Dependencies.KotlinPoet.metadata)
|
|
testImplementation(Dependencies.KotlinPoet.metadataSpecs)
|
|
testImplementation(Dependencies.KotlinPoet.elementsClassInspector)
|
|
testImplementation(Dependencies.Testing.junit)
|
|
testImplementation(Dependencies.Testing.truth)
|
|
testImplementation(Dependencies.Testing.compileTesting)
|
|
}
|
|
|
|
val relocateShadowJar = tasks.register<ConfigureShadowRelocation>("relocateShadowJar") {
|
|
target = tasks.shadowJar.get()
|
|
}
|
|
|
|
val shadowJar = tasks.shadowJar.apply {
|
|
configure {
|
|
dependsOn(relocateShadowJar)
|
|
archiveClassifier.set("")
|
|
configurations = listOf(shade)
|
|
relocate("com.squareup.kotlinpoet.metadata", "com.squareup.moshi.kotlinpoet.metadata")
|
|
relocate(
|
|
"com.squareup.kotlinpoet.classinspector",
|
|
"com.squareup.moshi.kotlinpoet.classinspector"
|
|
)
|
|
relocate("kotlinx.metadata", "com.squareup.moshi.kotlinx.metadata")
|
|
transformers.add(ServiceFileTransformer())
|
|
}
|
|
}
|
|
|
|
artifacts {
|
|
runtimeOnly(shadowJar)
|
|
archives(shadowJar)
|
|
}
|