Is there a short hand for gradle debug?

Like maven have mvnDebug vs mvn out of the box.
Does gradle? Rather than set/unset the OPTS everytime ?

> -Dorg.gradle.daemon.debug=true on https://docs.gradle.org/current/userguide/command_line_interface.html?&_ga=2.31264959.1270406471.1517316816-1028277259.1515509640#sec:command_line_debugging does not seem to be a vlid thing to pass on commandline
> 
> PS C:\Users\hoaphan\TestTask> gradle -Dorg.gradle.daemon.debug=true myTask
> 
> FAILURE: Build failed with an exception.
> 
> * What went wrong:
> Task '.gradle.daemon.debug=true' not found in root project 'TestTask'.
> 
> * Try:
> Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
> 
> * Get more help at https://help.gradle.org

I think the doc is wrong, also it does not make much sens to have -D…=true while default is already false. It should be a flag, if it does exist.

Gradle has the property org.gradle.debug. It can be set any way you can set a build property, including command line. Documentation references include command line debugging and gradle configuration properties.

Hold on, can you actually do
gradle -Dorg.gradle.daemon.debug=true myTask

I’m getting:

FAILURE: Build failed with an exception.

* What went wrong:
Task '.gradle.daemon.debug=true' not found in root project 'TestTask'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

you can try using :
gradle myTask --debug

Ah sorry I did before, that is for enablin DEBUG level of the logging, not pause and wait for remote debugger to connect.

Yes, I can run gradle -Dorg.gradle.daemon.debug=true myTask without an error.

I can only reproduce your error if I add an incorrect space between org and gradle so that it reads
gradle -Dorg .gradle.daemon.debug=true myTask
or omit -Dorg entirely, which makes sense to cause that error, but I’m also not on Windows.

However, I also only use gradle -Dorg.gradle.debug=true as it propagates the debug JVM arguments to the correct location for debugging Gradle or a Gradle plugin.

I swear there were no space in my opt :joy:

New photo by Hoa Phan

After struggling with the same issue. The “trick” in Windows is to wrap the -D argument with quotemarks.

./gradlew "-Dorg.gradle.debug=true" clean run

That’s actually neither a Windows thing, nor a Gradle thing.
That is PowerShell non-sense, which sees a dot and thinks it knows better than the user and preprocesses the commandline arguments in some way.
If you for example would have used CMD or Git Bash, no quoting would have been necessary.

And in almost all cases it is much easier to simply use the debug button of your IDE when running Gradle, which just works. At least in good IDEs like IntelliJ IDEA or Android Studio, no idea about the others. :smiley: