JuanKB1024
JuanKB1024

Reputation: 344

How to print all command line arguments passed to gradle?

I want to know what parameters is gradle receiving from my IDE.

So far, most documentation talks about passing custom properties but I want to be able to solve possible issues between my IDE and gradle.

So, how to print all command line arguments passed to gradle?

Upvotes: 2

Views: 1163

Answers (1)

RenatoIvancic
RenatoIvancic

Reputation: 2092

I'm not using NetBeans, but I can see command line arguments in IntelliJ. They are printed as first log line in the Run window. Maybe you have something similar.

See the line Executing task 'clean -i --console=plain'

enter image description here

Didn't find a way of how to debug command line argument options within Gradle.

For all other project and system properties and arguments to Gradle JVM itself you can use following script:

import java.lang.management.RuntimeMXBean
import java.lang.management.ManagementFactory

println("==== START EXT Gradle Properties ====")
project.properties.ext.properties.forEach{key, value ->
  println("KEY: $key, VALUE is: $value")
}
println("==== START Gradle Properties ====")
project.properties.forEach{key, value ->
  println("KEY: $key, VALUE is: $value")
}
println("==== START Gradle JVM Arguments ====")
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
List<String> jvmArgs = runtimeMXBean.getInputArguments();
for (String arg : jvmArgs) {
  System.out.println(arg);
}
println("==== START System Properties ====")
System.getenv()
System.getProperties().forEach{key, value ->
  println("KEY: $key, VALUE is: $value")
}

Upvotes: 1

Related Questions