We currently need to migrate an application from Grails 2.x to Grails 3.x
We do not know much about this application but in the past, in v2, it used Groovy classes inside Java classes.
After upgrading to v3, this doesn't seem to work anymore. Having Groovy code inside a Java class will return this
...: error: cannot find symbol
line of code with the error
^
symbol: variable MyGroovyClass
location: class MyJavaClass
MyJavaClass
public class MyJavaClass {
public void x() { MyGroovyClass.test(); }
}
MyGroovyClass
class MyGroovyClass {
static void test() { ... }
}
they are placed under src/main/java and src/main/groovy
The simple thing to do, and the thing that most Grails apps do, is put all of the Java and Groovy source code under src/main/groovy/
. That allows the Groovy joint compiler to compile all of it together as a single unit so you can have bidirectional dependencies between the Groovy and Java classes. It is possible to configure support for separate directories but it involves some complexity that doesn't really buy you anything, which is why the convention is to use src/main/groovy
/.