Gradle: custom task with jvm arguments for Spring Download

Trying to create a small custom gradle task for Spring Boot that initially looks like this:

gradle bootRun --debug-jvm

The task should look like this: gradle debugRun

I tried this, but it does not work:

 task debugRun(dependsOn: 'bootRun') << { applicationDefaultJvmArgs = ['--debug-jvm'] } 

How to pass this debug flag to bootRun task?

+2
source share
1 answer

It is not enough that the debug execution task is dependent on the bootRun task. To enable debugging, you must modify the existing bootRun task. This can be done by running the debugRun task in the Gradle task graph. If it is there, you set the bootRun task debug property to true :

 task debugRun(dependsOn:bootRun) { gradle.taskGraph.whenReady { graph -> if (graph.hasTask(debugRun)) { bootRun { debug = true } } } } 
+4
source

All Articles