I have upgraded from groovy 2.4.10 to 3.0.9 and it broke the static variable imports. I am using groovy-eclipse-compiler. Here are some implementation and the error details (I have created a minimal repo that reproduces the behavior. here's the link: https://github.com/avdhut1222/demo):
Dependency
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.9</version>
<type>pom</type>
</dependency>
Groovy Plugins
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.8-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.7.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>3.0.8-01</version>
</dependency>
</dependencies>
</plugin>
Source class
package com.srcpkg
class SrcClass {
static SomeClass staticVar
}
Destination class
package com.destpkg
import static com.srcpkg.SrcClass.staticVar
class DestClass {
method1 () {
String str = staticVar.str1
}
}
Error
ERROR in DestClass.groovy (at line 3)
import static com.srcpkg.SrcClass.staticVar
^^^^^^^^^^^^^^^^^^^^^^^^^^
The field SrcClass.com.srcpkg.SrcClass.staticVar is not visible
The static imports used to work with groovy 2.4.10 and corresponding versions of groovy-eclipse-compiler. Any pointers what's the issue here?
Thanks to @emilles for the answer (above comments). Posting the updated code here for destination class
package com.destpkg
import static com.srcpkg.SrcClass.getStaticVar
class DestClass {
method1 () {
String str = staticVar.str1
}
}