groovy 3.0.9 导入静态变量不起作用
我已经从 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 的版本。有任何指示这里有什么问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@emiles 的回答(以上评论)。在此处发布目标类的更新代码
Thanks to @emilles for the answer (above comments). Posting the updated code here for destination class