Problem
- Bind a simple
my.settings.groovyfile to Java code like this
String parent = "src/test/resources/test";
String child = "my.settings.groovy";
final CompilerConfiguration cc = new CompilerConfiguration();
cc.setScriptBaseClass(DelegatingScript.class.getName());
GroovyShell sh = new GroovyShell(SomeTest.class.getClassLoader(), new Binding(), cc);
DelegatingScript script = (DelegatingScript) sh.parse(new File(parent, child));
- The debugger doesn't stop inside
my.settings.groovyfile
Cause
my.settings.groovy is an illegal file name in Java specification.
Every Groovy script is compiled into a Java class that extends the groovy.util.DelegatingScript class. The class's name is taken from the Groovy script file name. IDEA will try to find the corresponding class file with the same groovy file name as the class name, then invoke the debug command to the JVM.
However, my.settings.groovy will be compiled into a class named my_settings.class, in this case, the IDE can't find the correct source file of my_settings.class, it will try to find my_settings.groovy to display the breakpoint.
Resolution
Use a legal file name without a dot in the name.
For example, settings.groovy or my_settings.groovy
Reference
https://stackoverflow.com/questions/51238868/forbidden-characters-in-groovy-script-filenames
Comments
0 comments
Please sign in to leave a comment.