Hey all, I found out that whenever using Gradle Ko...
# kotlin-dsl
a
Hey all, I found out that whenever using Gradle Kotlin DSL with SpringBoot plugin and running
gradle bootRun -Dspring.profiles.active=local
the profile is not set, it only works if I set env var like
SPRING_PROFILES_ACTIVE=local gradle bootRun
why is that? Does
-D<prop>=<value>
not work with Kotlin DSL?
e
This likely has nothing to do with the DSL language. The
-D
option only passes a system property to the JVM that is running Gradle, not to any of the invoked tasks. https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_system_properties If you want to specify the profile from the Gradle command line you will have to wire a Gradle property to add the system property to the
bootRun
task. https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html#org.gradle.api.tasks.JavaExec:systemProperties(java.util.Map)
a
I found this in their documentation: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#running-your-application.passing-arguments So maybe this works:
Copy code
./gradlew bootRun --args='--spring.profiles.active=local'
And below that it's also an example how to pass system properties to bootRun.
👍 1