我有一个gradle项目,要从中生成两个工件-一个Java jar和一个附加文件的压缩包。
所以我将以下内容添加到了build.gradle
def serviceName = "kafka-schemas"
task packageDistribution(type: Copy) {
from "$buildDir/resources/main"
include "*.avsc"
into "$buildDir/schemas"
}
task archive(type: Tar) {
dependsOn 'packageDistribution'
compression = 'GZIP'
from("$buildDir/schemas") {
include "**/*.avsc"
}
into("${serviceName}")
}
project.tasks.findByName('build') dependsOn archive
project.tasks.findByName('build') dependsOn packageDistribution
但是,当我运行gradle clean build
时,它不会运行我的任务。
我在做什么错了?
答案 0 :(得分:0)
尝试一下:
processResources.dependsOn('packageDistribution')
task packageDistribution(type: Zip) {
archiveFileName = "xxxxx.zip"
destinationDirectory = file("$buildDir/dist")
from "xxxx"
}