我尝试在IntelliJ中添加断点来调试foo.groovy,如下所示:
def binding = new Binding();
binding.lineList = [list1];
binding.count = 5;
def shell = new GroovyShell(binding);
def result = shell.evaluate(new File("../../not-src-main-groovy/foo.groovy"));这段代码可以很好地编译和运行,但是IntellIj不会在我的断点处停止。
另一方面,如果我将foo.groovy放在src/main/groovy/com/...中,那么IntellIJ确实会在我的断点处停止,就像这个stackoverflow answer中建议的那样。
但与那篇文章不同的是,foo.groovy做了多条import语句。这些语句引用了来自不同github存储库的代码,这些代码是在我的../../not-src-main-groovy项目之外本地克隆的。
我尝试过更改IntelliJ >项目结构>模块> mymodule >依赖项>+> JARS或目录> "../../not-src-main-groovy“,但IntelliJ没有在断点处停止。
如何将IntelliJ配置为在foo.groovy断点处停止?
发布于 2021-08-29 17:21:20
我找到了一个解决方案。因为我的项目使用gradle,所以我在build.gradle中添加了以下内容。
dependencies {
...
compile files("include-me/**")
...
}这样,gradle将在编译阶段将文件包含在类路径中,但不会实际编译它们,因为它们不在这里:
sourceSets {
main.groovy {
srcDirs = [ 'src/main/groovy']
}
}https://stackoverflow.com/questions/68967262
复制相似问题