【发布时间】:2020-06-09 14:12:41
【问题描述】:
gradle 6.x release notes 告诉我们 boot-jars 的 maven-publishing 不起作用,因为 spring-boot 插件禁用了默认的 jar 任务。
一种解决方法是告诉 Gradle 要上传什么。如果要上传 bootJar,则需要配置传出配置来执行此操作:
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(bootJar)
}
}
不幸的是,我所有将其转换为 gradle-kotlin-dsl 的尝试都失败了:
configurations {
listOf(apiElements, runtimeElements).forEach {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(bootJar)
}
}
* What went wrong:
Script compilation errors:
it.outgoing.artifacts.removeAll { it.buildDependencies.getDependencies(null).contains(jar) }
^ Out-projected type 'MutableSet<CapturedType(out (org.gradle.api.Task..org.gradle.api.Task?))>' prohibits the use of 'public abstract fun contains(element: E): Boolean defined in kotlin.collections.MutableSet'
it.outgoing.artifacts.removeAll { it.buildDependencies.getDependencies(null).contains(jar) }
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public val TaskContainer.jar: TaskProvider<Jar> defined in org.gradle.kotlin.dsl
it.outgoing.artifact(bootJar)
^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public val TaskContainer.bootJar: TaskProvider<BootJar> defined in org.gradle.kotlin.dsl
关于如何在 Gradle Kotlin DSL 中执行此常规解决方法的任何想法?
【问题讨论】:
标签: gradle kotlin gradle-kotlin-dsl spring-boot-gradle-plugin maven-publish