Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass system properties to the tests in gradle in the smart way?

build.gradle

tasks.withType(Test){
    systemProperties=System.properties
    println systemProperties['param']
}

Now I can either pass parameters in the command line:

gradle test -Dparam=10

or put them in gradle.properties:

systemProp.param=15

Ideally I would like to put the defaults in the gradle.properties, and be able to overwrite them from the command line. Unfortunately if I do that, the gradle.properties has precedence, and -Dparam=10 is ignored.

Could you offer any solutions on that?

like image 927
Alexei Vinogradov Avatar asked Jun 30 '16 14:06

Alexei Vinogradov


1 Answers

https://issues.gradle.org/browse/GRADLE-2122

It works since 2.12 or 2.13 "the smart way" already!

The example above is working, the command line -D option overdrives the defaults in gradle.properties

like image 170
Alexei Vinogradov Avatar answered Oct 14 '22 02:10

Alexei Vinogradov