How to set system property using gradle?

I just stumbled on this for use with the gradle application plugin. Add to the run task. Works great:

run {   
    systemProperties['MYPROP'] = '/my/prop/value'
}

This is how I do it, setting props for Selenide test framework:

test {
    systemProperty "browser", "chrome"
    systemProperty "webdriver.chrome.driver", "$projectDir/drivers/chromedriver"
}

The system property set in gradle.properties will be available only in JVM where Gradle is running.

From gradle-appengine-plugin documentation:

appengineRun: Starts a local development server running your project code.

jvmFlags: The JVM flags to pass on to the local development server.

If you need your system properties to be available in app engine, which is separate JVM, you should use jvmFlags property.

Explicitly:

appengine {
    jvmFlags = ['-DfirstName=Marko', '-DlastName=Vuksanovic']
}

With gradle.properties:

appengine {
    jvmFlags = ['-DfirstName=$firstName', '-DlastName=$lastName']
}

Tags:

Gradle