Gradle 6.x发布说明告诉我们,由于spring-boot插件禁用了默认的jar
任务,因此maven-publish
无法使用boot-jars。
解决方法是告诉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中实现这个Groovy解决方案的想法?