我用这个代码来获得所需要的库和编译过程中复制它们:
task copyToLib( type: Copy ) {
into "$buildDir/libs/lib"
from configurations.runtime
}
jar {
dependsOn copyToLib
...
}
这是确定的,当我使用旧的摇篮模型添加使用qazxsw POI依赖关系:
compile
但是当我使用dependencies {
compile 'net.objecthunter:exp4j:0.4.8'
compile 'io.undertow:undertow-core:2.0.16.Final'
compile 'org.postgresql:postgresql:42.2.5'
...
}
关键字:
api
该dependencies {
api 'net.objecthunter:exp4j:0.4.8'
api 'io.undertow:undertow-core:2.0.16.Final'
api 'org.postgresql:postgresql:42.2.5'
...
}
将是空的。任何替代方案?
该configurations.runtime
配置也被弃用,就像runtime
配置(见文档在这里:compile
)
所以,你需要改变你的https://docs.gradle.org/4.10/userguide/java_plugin.html#tab:configurations子句中from
任务,拿起一个正确的配置:我觉得你的情况,你应该使用copyToLib
(编辑使用compileClasspath
代替,见下面的评论):
runtimeClasspath
看到这个配置的依赖关系图,可以帮助你拿起正确的配置:dependencies {
api 'net.objecthunter:exp4j:0.4.8'
api 'org.postgresql:postgresql:42.2.5'
api 'io.undertow:undertow-core:2.0.16.Final'
}
task copyToLib(type: Copy) {
into "$buildDir/libs/lib"
from configurations.runtimeClasspath
}