Gradle 加载 Groovy 3 个库
Gradle to load Groovy 3 library
我正在使用这些行将 groovy 3.0.3 库添加到项目中。我不喜欢在 build.gradle
文件中对路径进行硬编码。有没有更好的方法将 Groovy 3.0 库包含到项目中?
implementation 'org.codehaus.groovy:groovy-all:3.0.3'
compile fileTree(dir: 'C:\Software\groovy-3.0.3\lib', includes: ['*.jar'])
谢谢
SR
如果我删除编译行得到这个错误。
Starting Gradle Daemon...
Gradle Daemon started in 7 s 310 ms
> Task :compileJava
> Task :compileGroovy
startup failed:
C:\work\src\main\groovyCheckCertificate.groovy: 2: unable to resolve class groovy.yaml.YamlSlurper
@ line 2, column 1.
import groovy.yaml.YamlSlurper
^
1 error
> Task :compileGroovy FAILED
根据 maven repo,groovy-all
工件不包含 groovy-yaml
模块。
这意味着,您的依赖项应明确包含它:
implementation 'org.codehaus.groovy:groovy-all:3.0.3'
implementation 'org.codehaus.groovy:groovy-yaml:3.0.3'
或
implementation 'org.codehaus.groovy:groovy-all:3.0.3', 'org.codehaus.groovy:groovy-yaml:3.0.3'
我正在使用这些行将 groovy 3.0.3 库添加到项目中。我不喜欢在 build.gradle
文件中对路径进行硬编码。有没有更好的方法将 Groovy 3.0 库包含到项目中?
implementation 'org.codehaus.groovy:groovy-all:3.0.3'
compile fileTree(dir: 'C:\Software\groovy-3.0.3\lib', includes: ['*.jar'])
谢谢 SR
如果我删除编译行得到这个错误。
Starting Gradle Daemon...
Gradle Daemon started in 7 s 310 ms
> Task :compileJava
> Task :compileGroovy
startup failed:
C:\work\src\main\groovyCheckCertificate.groovy: 2: unable to resolve class groovy.yaml.YamlSlurper
@ line 2, column 1.
import groovy.yaml.YamlSlurper
^
1 error
> Task :compileGroovy FAILED
根据 maven repo,groovy-all
工件不包含 groovy-yaml
模块。
这意味着,您的依赖项应明确包含它:
implementation 'org.codehaus.groovy:groovy-all:3.0.3'
implementation 'org.codehaus.groovy:groovy-yaml:3.0.3'
或
implementation 'org.codehaus.groovy:groovy-all:3.0.3', 'org.codehaus.groovy:groovy-yaml:3.0.3'