gradle 6.x release notes tells us that maven-publish
ing of boot-jars doesn't work because the default jar
task is disabled by the spring-boot plugin.
A workaround is to tell Gradle what to upload. If you want to upload the bootJar, then you need to configure the outgoing configurations to do this:
configurations {
[apiElements, runtimeElements].each {
it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
it.outgoing.artifact(bootJar)
}
}
unfortunately all my tries to translate this to gradle-kotlin-dsl fail:
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
any idea on how to do this groovy workaround in Gradle Kotlin DSL?
jar
and bootJar
seems to be Gradle tasks. You can get a reference to a task in Kotlin DSL like this:
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)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With