Gradle attempts to make builds as reproducible as possible. As such, the behavior of JavaExec
tasks like bootRun
is to not propagate system, environments, args, etc. to the forked JVM unless you explicitly set them on the task. Those task properties can be hard-coded in the build.gradle
or set with properties that can be controlled from the command line, but you can’t really avoid doing something in build.gradle
if you want to impact the Spring Boot JVM.
The build.gradle
files should be almost entirely declarative, just setting the values you need, but it sounds like this is not what you have. Having come from a web application that started with 10,000+ lines in build.gradle
to now having only a few hundred declarative lines (mostly plugins and dependencies now), I’m always wary of attempts to circumvent the intended design. One workaround leads to another until you’re adding more to the confusion that you hoped to avoid (and you have 10,000+ lines to untangle).