我使用Spring Boot(1.0.0.RELASE),我想创建一个包含以下内容的分发zip文件:
我希望在运行" gradle build"时创建这个zip文件。 (但如果很难实现,另一项任务很好)。有没有很好的方法来实现这一目标?
答案 0 :(得分:9)
这样的东西?
task zip(type: Zip, dependsOn: bootRepackage) {
from('build/libs') {
include '*.jar'
}
from 'conf'
}
build.dependsOn(zip)
答案 1 :(得分:1)
我做了类似于Dave Syer建议的事情:
task zip(type: Zip, dependsOn: bootRepackage) {
def fileName = "${jar.baseName}-${jar.version}"
from projectDir
include "script.sh"
from file("$buildDir/libs")
include "${fileName}.jar"
from file('src/dist')
include "config/application.yml"
archiveName "${fileName}.zip"
}
build.dependsOn(zip)
欢迎任何改进建议。