Passing system properties into Spring Boot from Gradle
<p>I want to pass certain security sensitive properties into my Spring Boot application, which I start via Gradle during development, via command-line and/or externally set system properties. I can't write these into things like the build.gradle script or properties files because they will be committed into source control and will then be publicly available.</p>

<p>I cannot get any of the solutions I've found for making these values available to an application Gradle executes to work using Gradle 2.4.4.</p>

<p>Several solutions look like this, where the system properties are set in the bootRun task:</p>

<pre><code>bootRun {
    systemProperties System.properties
}
</code></pre>

<p>This appears to completely overwrite the default bootRun task and breaks Spring Boot's automatic main class detection.</p>

<p>Somewhere else this was suggested:</p>

<pre><code>bootRun {
    run {systemProperties System.properties}
}
</code></pre>

<p>This doesn't override the normal configuration, but the properties set inside the run closure are not available inside the bootRun task.</p>

<p>This all occurs when I launch Gradle using Intellij. </p>

<p>If I start Gradle from the command-line and attempt to pass in a property way, for example:</p>

<pre><code>gradle -Dspring.email.password=123 bootRun
</code></pre>

<p>The property is never set anywhere, regardless of configuration. Changing the order of the arguments has no effect.</p>