I want to add dependency on spring-boot-devtools
but only for development.
I try to achieve this by having this snippet in my build.gradle
:
if (project.hasProperty('use-spring-boot-devtools')) {
compile 'org.springframework.boot:spring-boot-devtools'
}
Then I can define in my ~/.gradle/gradle.properties
use-spring-boot-devtools = true
Unfortunately this doesn't work when I run import project in IDEA. I would like to use answer to related question but still can't figure out how to define environment variable that will affect gradle inside IDEA.
Do not use hyphens to concat your key in the
gradle.properties
. Instead define it in camel case:And for your
build.gradle
file, use the following syntax for your conditional dependency:Make sure to append
toBoolean()
to your key since it's not casted automatically by Gradle.