mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 07:59:21 +08:00
Fix shadow packaging in code gen artifact (#1214)
* Update to shadow 6.0 * Exclude kotlinpoet core artifact from shading * Replace runtime scopes with compile * Opportunistically fix old artifact() dep Gradle 6.6 supports providers now * Use api instead * Add link * Remove accidental gradle plugin config This only applies to gradle plugins
This commit is contained in:
@@ -22,7 +22,7 @@ plugins {
|
||||
kotlin("jvm")
|
||||
kotlin("kapt")
|
||||
id("com.vanniktech.maven.publish")
|
||||
id("com.github.johnrengelman.shadow") version "5.2.0"
|
||||
id("com.github.johnrengelman.shadow") version "6.0.0"
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
@@ -38,26 +38,31 @@ tasks.withType<KotlinCompile>().configureEach {
|
||||
val shade: Configuration = configurations.maybeCreate("compileShaded")
|
||||
configurations.getByName("compileOnly").extendsFrom(shade)
|
||||
dependencies {
|
||||
implementation(project(":moshi"))
|
||||
implementation(kotlin("reflect"))
|
||||
// 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")
|
||||
}
|
||||
implementation(Dependencies.KotlinPoet.kotlinPoet)
|
||||
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")
|
||||
}
|
||||
shade(Dependencies.KotlinPoet.elementsClassInspector) {
|
||||
exclude(group = "org.jetbrains.kotlin")
|
||||
exclude(group = "com.squareup", module = "kotlinpoet")
|
||||
}
|
||||
implementation(Dependencies.asm)
|
||||
api(Dependencies.asm)
|
||||
|
||||
implementation(Dependencies.AutoService.annotations)
|
||||
api(Dependencies.AutoService.annotations)
|
||||
kapt(Dependencies.AutoService.processor)
|
||||
implementation(Dependencies.Incap.annotations)
|
||||
api(Dependencies.Incap.annotations)
|
||||
kapt(Dependencies.Incap.processor)
|
||||
|
||||
// Copy these again as they're not automatically included since they're shaded
|
||||
@@ -94,18 +99,3 @@ artifacts {
|
||||
runtime(shadowJar)
|
||||
archives(shadowJar)
|
||||
}
|
||||
|
||||
// Shadow plugin doesn't natively support gradle metadata, so we have to tell the maven plugin where
|
||||
// to get a jar now.
|
||||
afterEvaluate {
|
||||
configure<PublishingExtension> {
|
||||
publications.withType<MavenPublication>().configureEach {
|
||||
if (name == "pluginMaven") {
|
||||
// This is to properly wire the shadow jar's gradle metadata and pom information
|
||||
setArtifacts(artifacts.matching { it.classifier != "" })
|
||||
// Ugly but artifact() doesn't support TaskProviders
|
||||
artifact(shadowJar.get())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user