gradle - Gradle JAR 创建时间
问题描述
我有一个 gradle 构建,它可以检索属性文件,并且这些文件是远程的(将密码保存在 github 之外),但是在构建 JAR 时远程检索还没有完成。
我想我要么必须在执行阶段而不是配置阶段创建 JAR,要么在执行阶段添加远程文件,但我无法工作。
有什么建议么?
task fatJar(type: Jar) {
doFirst {
exec {
executable './scripts/getRemoteResources.sh'
}
}
...
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it)
}
//some resources are retrieved remotely & b/c of timing they don't get included here
from ('src/main/java/resources') {
include '*'
}
with jar
//tried this but doesn't work
//doLast {
// jar {
// from ('src/main/java/resources') {
// include '*'
// }
// }
//}
}
解决方案
这似乎可行,所以除非有人有更好的解决方案,否则我将继续使用它...
gradle.taskGraph.beforeTask { Task task ->
println "just before $task.name"
// i just chose to kick this off with the first task sent through here
if (task.name=="compileJava") {
exec {
executable './scripts/getRemoteResources.sh'
}
}
}
task fatJar(type: Jar) {
...
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it)
}
from ('src/main/java/resources') {
include '*'
}
with jar
}
推荐阅读
- f# - F# 和 Series,如何编写 Series.choose?
- configure - 在 MobaXterm 上编译 Poly/ML:ar u 选项
- python - 如何使用 np.arange 获取一组值?
- elixir - 如何使 Plug.ErrorHandler 和其他 Plug 同时工作?
- java - 如何从 xsd 生成 Json 兼容的 POJO
- php - 创建每个数组项的路径
- firebase - 如何在 cloudbuild 中使用 firebase 持续部署?
- sql-server-2012 - 使用 SSMS“生成和发布脚本向导”生成的存储过程计数不同
- mysql - 将不同的计数查询分组到一个结果表中
- javascript - 吊装内部功能