1

Gradle 2.14 and Groovy 2.4.7 here. I have the following Groovy:

@Slf4j
class Driver {
    static void main(String[] args) {
        log.info("Fizz prop value is: ${System.properties['fizz']}.")
    }
}

I'm using the Gradle Application plugin. When I run:

./gradlew run -Pfizz=buzz

I get he following console output:

[main] INFO com.me.myapp.Driver - Fizz prop value is: null.

Why does my app think the fizz property is null, when I am passing its value as buzz on the command-line?

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • http://stackoverflow.com/questions/23689054/problems-passing-system-properties-and-parameters-when-running-java-class-via-gr – tim_yates Jun 15 '16 at 20:16
  • http://stackoverflow.com/questions/27604283/gradle-task-pass-arguments-to-java-application – tim_yates Jun 15 '16 at 20:17

2 Answers2

1

You are passing it with -P which are properties for gradle

Try passing it with -D

tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • Thanks @tim_yates (+1) - but `./gradlew run -Dfizz=buzz` still produces the same output (`null`). – smeeb Jun 16 '16 at 01:05
0

try without the System.properties and passing -Pfizz=buzz:

log.info("Fizz prop value is: ${fizz}.")
Tidhar Klein Orbach
  • 2,896
  • 2
  • 30
  • 47