Hi, I’d like to create a Gradle Task for my Spring...
# gradle
c
Hi, I’d like to create a Gradle Task for my Spring Boot App that allows me to start it with a property set:
Copy code
tasks.register("bootRunDev") {
  System.setProperty("spring.profiles.active", "dev")
  finalizedBy(tasks.bootRun)
}
However, this is not working - the property is not recognized. I also tried to extend the
BootRun
Profile:
Copy code
task<BootRun>("bootRunDev") {
  systemProperties["spring.profiles.active"] = "dev"
  dependsOn("bootRun")
}
Both approaches don’t work. Is there a way to do it?
l
You can do this:
Copy code
tasks.create("bootRunDev") {
    val bootRun: BootRun by project.tasks
    bootRun.args = listOf("--spring.profiles.active=dev")
    dependsOn(bootRun)
}