我假设我的问题(gradle任务的位置重要吗?)的答案是否,但是当我更改任务位置时,会看到奇怪的结果。
当我运行下面提到的 build.gradle 的任务./gradlew generateMifSrcZip
时,由于该错误而失败
* What went wrong:
A problem occurred evaluating root project 'tpae'.
> Could not get unknown property 'releaseForMIFSrcZip' for root project 'tpae' of type org.gradle.api.Project.
但是当我改变位置时,例如,如果像下面这样在releaseForMIFSrcZip
之前写generateMifSrcZip
,并且如果我运行./gradlew generateMifSrcZip
的话,那就很好了。
task(releaseForMIFSrcZip) {
//Assume same code here as defined below
}
task generateMifSrcZip(type: Zip, dependsOn: releaseForMIFSrcZip) {
//Assume same code here as defined below
}
不确定为什么会这样,完全感到困惑,是否有人 关于这个为什么发生的想法?
build.gradle
task generateMifSrcZip(type: Zip, dependsOn: releaseForMIFSrcZip) {
from distOutMifSrcZip
include '**'
archiveName 'MIF7610.src.zip'
destinationDir(file(distOutMifSrcZip))
zip64 true
println "Mac OS Sierra's Archive Utility notably does not support ZIP64, and can create corrupt archives when ZIP64 would be required."
println "Earlier windows before Vista might not support ZIP64, and can create corrupt archives when ZIP64 would be required."
}
task(releaseForMIFSrcZip) {
println "Making distOutMifSrcZip dir ${distOutMifSrcZip}"
mkdir(distOutMifSrcZip)
doLast {
println "Packaging..."
// copy Maximo-7.6-CD
copy {
from '../Maximo-7.6-CD'
into distOutMifSrcZip
include '*'
include '**/*'
}
// copy MIF
copy {
from '../7.6CD-MIF'
into distOutMifSrcZip
include '*'
include '**/*'
}
}
}