Hi,
the user guide has a nice example on how to generate different version
number for release build by evaluating the taskGraph. How can I use
this together with Zip tasks? I need the version number in my zip
task, but the task gets fully evaluated and all variables expanded on
task creation. It's too late to change the project version number
after that.
Here is a minimal example:
build.gradle:
usePlugin "java"
task release(dependsOn: 'dist') << {
println "Created release for version ${version}"
}
task dist(type: Zip) {
println "Created zip task with version $version"
zipFileSet(dir: projectDir, prefix: "$name-$version") {
include("build.gradle")
}
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(':release')) {
version = "1.0"
} else {
version = "1.0-SNAPSHOT"
}
println "Version set to $version"
}
When I run gradle dist, I get the following output:
Created zip task with version unspecified
Version set to 1.0-SNAPSHOT
:dist
BUILD SUCCESSFUL
You can see that the version numbers get set too late. The zip file
that is created is: build/distributions/myproject-unspecified.zip
Any ideas?
Thanks,
--Peter
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email