Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么我不能调试Gradle构建脚本的每一行?_Java_Debugging_Gradle_Groovy_Remote Debugging - Fatal编程技术网

Java 为什么我不能调试Gradle构建脚本的每一行?

Java 为什么我不能调试Gradle构建脚本的每一行?,java,debugging,gradle,groovy,remote-debugging,Java,Debugging,Gradle,Groovy,Remote Debugging,当使用典型的命令行args-Xdebug-Xrunjdwp远程调试gradle构建时:transport=dt_socket,server=y,suspend=n,address=5005,我只能在我提供的类中的断点上停止;我无法在构建脚本本身中停止 根据各种来源,这显然是一种预期行为,包括。例如: apply plugin: 'groovy' // not able to stop debugger here class Penguin() { def ork() {

当使用典型的命令行args-Xdebug-Xrunjdwp远程调试gradle构建时:transport=dt_socket,server=y,suspend=n,address=5005,我只能在我提供的类中的断点上停止;我无法在构建脚本本身中停止

根据各种来源,这显然是一种预期行为,包括。例如:

apply plugin: 'groovy'  // not able to stop debugger here

class Penguin() {
    def ork() {
        println 'ork!'  // able to stop debugger here
    }
}

new Penguin().ork()
我在想为什么会这样?为什么Gradle不允许调试构建脚本中的每一行


谢谢大家!

虽然build.gradle文件与groovy非常相似,但它是一个由gradle解析的自定义DSL。断点只能添加到.java或.groovy文件中,并且没有可添加断点的文件

我相信如果您使用而不是groovy DSL,您可能能够在kotlin构建脚本中设置断点,并在IntelliJ IDEA中进行调试,但我不能100%确定这一点

如果你真的想调试,你可以把所有的东西都放到一个插件上,这个插件可以调试,并且在build.gradle中只有一行

$root/build.gradle

apply plugin: MyBuildScript
$root/buildSrc/src/main/groovy/MyBuildScript.groovy

import org.gradle.api.*
class MyBuildScript implements Plugin<Project> {
    void apply(Project project) {
        project.with {
            apply plugin: 'foo'
            dependencies { ... }
            task bar(type: Baz) { ... }
            // etc
        }
    }
}