Search code examples
gradlegroovysystem-properties

Why won't Gradle pass runtime args to Groovy?


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?


Solution

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

    Try passing it with -D