我有一个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 '*'
  //    }
  //  }
  //}
}发布于 2021-06-24 18:16:53
这似乎是可行的,所以我同意,除非有人有更好的解决办法.
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
}https://stackoverflow.com/questions/68120244
复制相似问题