smeeb
smeeb

Reputation: 29537

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?

Upvotes: 1

Views: 93

Answers (2)

Tidhar Klein Orbach
Tidhar Klein Orbach

Reputation: 2966

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

log.info("Fizz prop value is: ${fizz}.")

Upvotes: 0

tim_yates
tim_yates

Reputation: 171114

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

Try passing it with -D

Upvotes: 1

Related Questions