我已经从 groovy 2.4.10 升级到 3.0.9,它破坏了静态变量导入。我正在使用 groovy-eclipse-compiler。以下是一些实现和错误详细信息(我创建了一个重现该行为的最小存储库。这是链接:https ://github.com/avdhut1222/demo ):
依赖
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.9</version>
<type>pom</type>
</dependency>
Groovy 插件
<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>
源类
package com.srcpkg
class SrcClass {
static SomeClass staticVar
}
目的地等级
package com.destpkg
import static com.srcpkg.SrcClass.staticVar
class DestClass {
method1 () {
String str = staticVar.str1
}
}
错误
ERROR in DestClass.groovy (at line 3)
import static com.srcpkg.SrcClass.staticVar
^^^^^^^^^^^^^^^^^^^^^^^^^^
The field SrcClass.com.srcpkg.SrcClass.staticVar is not visible
静态导入用于 groovy 2.4.10 和相应版本的 groovy-eclipse-compiler。任何指针这里有什么问题?