所以我创建了一个档案,比如说一个war,然后为了方便,我想要另一个名字不同的副本。问题是,我不希望复制任务减缓这个相当大的构建的其余部分。有可能异步执行吗?如果是这样的话,是怎么做的?
发布于 2016-08-19 18:20:44
import java.util.concurrent.*
...
def es = Executors.newSingleThreadExecutor()
...
war {
...
doLast{
es.submit({
copy {
from destinationDir.absolutePath + File.separator + "$archiveName"
into destinationDir
rename "${archiveName}", "${baseName}.${extension}"
}
} as Callable)
}
}发布于 2016-08-12 10:31:48
在某些情况下,使用并行执行特征进行此操作非常方便。它只适用于多项目构建(您希望并行执行的任务必须在单独的项目中执行)。
project('first') {
task copyHugeFile(type: Copy) {
from "path/to/huge/file"
destinationDir buildDir
doLast {
println 'The file is copied'
}
}
}
project('second') {
task printMessage1 << {
println 'Message1'
}
task printMessage2 << {
println 'Message2'
}
}
task runAll {
dependsOn ':first:copyHugeFile'
dependsOn ':second:printMessage1'
dependsOn ':second:printMessage2'
}默认输出:
$ gradle runAll
:first:copyHugeFile
The file is copied
:second:printMessage1
Message1
:second:printMessage2
Message2
:runAll用--parallel输出
$ gradle runAll --parallel
Parallel execution is an incubating feature.
:first:copyHugeFile
:second:printMessage1
Message1
:second:printMessage2
Message2
The file is copied
:runAllhttps://stackoverflow.com/questions/38905329
复制相似问题