编辑:我正在尝试运行这两个命令并在 gradle 子项目中获得这些结果......
gradle assemble -> databus-Developer-Build.zip
gradle -DmyVersion=1.0.2 -> databus-1.0.2.zip
目前,如果我使用 $version 而不是 $myVersion,我的输出是 databus-null.zip。使用 $MyVersion 时,我收到错误“myVersion 不是该任务的属性”。:( :(。
编辑
因此,尝试第一个答案完全失败了“在任务':webserver:myZip”上找不到属性$ myVersion
注意:我现在正在尝试在子项目中执行此操作。这是子项目的gradle代码...
project(':webserver') {
project.ext.genLibDir = file('lib')
project.ext.fixedLibDir = file('../master/libother')
dependencies {
compile project(':master')
compile fileTree(dir: '../webserver/lib', include: '*.jar')
compile fileTree(dir: '../webserver/play-1.2.4/framework/lib', include: '*.jar')
compile fileTree(dir: '../webserver/play-1.2.4/framework', include: 'play-*.jar')
}
task deleteJars(type: Delete) {
ext.collection = files { genLibDir.listFiles() }
delete ext.collection
}
task copyJars(type: Copy) {
from(configurations.compile) {}
from(fixedLibDir) {}
into genLibDir
}
copyJars.dependsOn('deleteJars')
classes.dependsOn('copyJars')
task myZip(type: Zip) {
archiveName "dashboard-"+$myVersion+".zip"
from('..') {
include 'webserver/run*.sh'
include 'webserver/app/**'
include 'webserver/conf/**'
include 'webserver/play-1.2.4/**'
include 'webserver/public/**'
}
}
assemble.dependsOn('myZip')
//playframework has it's own generation of .classpath and .project fils so do not
//overwrite their versions. NEED to call "play.bat eclipsify" here...
task eclipse(overwrite: true) {
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(assemble) && myVersion == null) {
myVersion = 'Developer-Build'
}
}
}
谢谢,院长