gradle 6.x release notes告诉我们maven-publish-jar的启动不起作用,因为默认的jar任务被spring-boot插件禁用了。
一种解决方法是告诉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中做这个出色的变通方法的想法?
发布于 2020-02-26 04:48:12
jar和bootJar似乎是Gradle任务。您可以在Kotlin DSL中获得对任务的引用,如下所示:
configurations {
listOf(apiElements, runtimeElements).forEach {
// Method #1
val jar by tasks
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
// Method #2
it.outgoing.artifact(tasks.bootJar)
}
}https://stackoverflow.com/questions/60401481
复制相似问题