What is equivalent for bootRepackage.enabled=false
for Spring Boot's latest Gradle plugin (2.0.0) ? bootJar.enabled=false
is not working
More details: https://github.com/gradle/kotlin-dsl/issues/488
Full project to reproduce:
https://github.com/xmlking/reactive-apps/blob/master/shared/build.gradle.kts
Comment From: wilkinsona
I don't think we need two issues to track the same problem. Given that this works for you with earlier versions of Gradle and that the BootJar
task inherits the enabled
property from Gradle's AbstractTask
, I am going to close this one in favour of the Gradle issue you also opened.
You may want to consider improving your build's configuration so that Spring Boot's plugin isn't applied to the shared project. It doesn't appear to be a Spring Boot application so applying the plugin is counter-productive. If you still wish to use Spring Boot's dependency management, you could import the spring-boot-dependencies
bom using the dependency management plugin (which I see you are already using directly).
Comment From: xmlking
Agree. Looks like it is gradle kotlin DSL issue. The following worked.
import org.gradle.api.tasks.bundling.Jar
import org.springframework.boot.gradle.tasks.bundling.BootJar
val jar: Jar by tasks
val bootJar: BootJar by tasks
bootJar.enabled = false
jar.enabled = true
Comment From: jelovac
I've been using it like this in latest build.gradle.kts
in order to be able to compile to jar Spring Boot 2.x based library:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
tasks.getByName<BootJar>("bootJar") {
enabled = false
}
tasks.getByName<Jar>("jar") {
enabled = true
}
Comment From: ixre
I tried some times and success finally! see below code:
plugins{
base
id("org.springframework.boot") version("2.3.4.RELEASE")
id("io.spring.dependency-management") version ("1.0.7.RELEASE")
kotlin("jvm") version("1.4.10")
kotlin("plugin.spring") version("1.4.10")
}
tasks.bootJar {enabled = false}
tasks.jar {enabled = true}
group = "demo"
version="1.0"
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "kotlin")
apply(plugin = "org.springframework.boot")
apply(plugin = "io.spring.dependency-management")
dependencies {
"implementation"("mysql:mysql-connector-java:5.1.38")
}
}
project(":sub"){
tasks.bootJar{ enabled = true }
}
```