Eri*_*ang 5 groovy gradle build.gradle
build.gradle - 部分:
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.15'
}
Run Code Online (Sandbox Code Playgroud)
如果更改compile为implementation,在构建时将出现以下错误:
任务 ':greeter:compileJava 执行失败
改回去然后构建就会成功。
尖端:
Gradle 4.10,里面做支持implementation。implementation不会导致问题,只有这一行会导致问题。有什么帮助吗?
我想知道为什么你的主java项目需要它,groovy-all因为它用于编译groovy库。implementation配置应该够用了。
感谢您的链接,我确实重现了您的问题并重点关注错误:
:greeter:compileJava FAILED
/mnt/star/git_repository/workspace/groovy_workplace/gradle/hello/hello_multi_project/greeter/src/main/java/greeter/Greeter.java:5: error: cannot access GroovyObject
final String output = GreetingFormatter.greeting(args[0]);
^
class file for groovy.lang.GroovyObject not found
Run Code Online (Sandbox Code Playgroud)
为什么GroovyObject需要编译你的java代码?我查看了GroovyObject源代码,它让我震惊:
package groovy.lang;
/**
* The interface implemented by all Groovy objects.
* <p>
* Especially handy for using Groovy objects when in the Java world.
*
* @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
*/
public interface GroovyObject {
[...]
Run Code Online (Sandbox Code Playgroud)
所有 Groovy 对象实现的接口。在 Java 世界中使用 Groovy 对象特别方便 。
GreetingFormatter是一个 Groovy 对象并隐式实现GroovyObject. 这就是为什么groovy-all在编译类路径中需要它,即应该将其声明为compilegroovy 库中的依赖项。
| 归档时间: |
|
| 查看次数: |
1062 次 |
| 最近记录: |