我正在尝试创建一个自定义的Gradle 4.3.1任务:
./gradlew build
工件的build/libs/myapp.jar
;然后myapp-1.0.zip
ZIP文件,其内容包括:
build/libs/myapp.jar
;和./AppGuide.md
;和./app-config.json
这是我最好的尝试:
task zipMeUp(type: Zip) {
String zipName = 'myapp-1.0.zip'
doFirst {
tasks.build
}
from 'build/libs/myapp.jar'
from 'AppGuide.md'
from 'app-config.json'
into zipName
}
当我运行它(./gradlew zipMeUp
)时,我得到以下输出:
HarveyZ:myapp myuser$ ./gradlew zipMeUp
BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
但实际上似乎没有发生任何事情(目录中没有myapp-1.0.zip
文件)。 知道修复/解决方案是什么吗?
答案 0 :(得分:1)
请勿使用doFirst
,请使用dependsOn
task zipMeUp(type:Zip, dependsOn :[build]) {
String zipName = 'myapp-1.0.zip'
from 'build/libs/myapp.jar'
from 'AppGuide.md'
from 'app-config.json'
version = "1.0"
baseName = "myapp"
}