Gradle:用于Spring Boot的jvm参数的自定义任务 [英] Gradle: custom task with jvm arguments for Spring Boot
问题描述
$ b
gradle bootRun --debug-jvm
任务应该如下所示: gradle debugRun
我试过这个,但它不起作用:
任务debugRun(dependsOn:'bootRun')< ;< {
applicationDefaultJvmArgs = ['--debug-jvm']
}
如何将此调试标志传递给bootRun任务?
这对于 debug
运行任务依赖于 bootRun
任务。它需要修改现有的 bootRun
任务来启用调试。你可以通过检查Gradle的任务图中的 debugRun
任务来完成。如果它在那里,您将 bootRun
任务的 debug
属性设置为 true
任务debugRun(dependsOn:bootRun){
gradle.taskGraph.whenReady {graph - >
if(graph.hasTask(debugRun)){
bootRun {
debug = true
}
}
}
}
Trying to create a small custom gradle task for Spring Boot that originally 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 can I pass this debug-flag to the bootRun task?
It isn't sufficient for your debug
run task to depend on the bootRun
task. It needs to modify the existing bootRun
task to enable debugging. You can do that by checking for the debugRun
task in Gradle's task graph. If it's there, you set the bootRun
task's debug
property to true
:
task debugRun(dependsOn:bootRun) {
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(debugRun)) {
bootRun {
debug = true
}
}
}
}
这篇关于Gradle:用于Spring Boot的jvm参数的自定义任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!