|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Using -SNAPSHOT version for non release builds together with zip taskHi,
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 |
|
|
Re: Using -SNAPSHOT version for non release builds together with zip taskHi Peter,
On Oct 21, 2009, at 11:30 AM, Peter Voss wrote: > 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") > } > } The zipFileSet is the problem. In 0.8 it does early evaluation. This is fixed in trunk where it evaluates late. As a work around you can do: task dist(type: Zip) { println .... doFirst { task -> task.zipFileZet ... } - Hans -- Hans Dockter Gradle Project Manager http://www.gradle.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Using -SNAPSHOT version for non release builds together with zip taskHi Hans,
On 25.10.2009, at 06:00, Hans Dockter wrote: > Hi Peter, > > On Oct 21, 2009, at 11:30 AM, Peter Voss wrote: > >> 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") >> } >> } > > The zipFileSet is the problem. In 0.8 it does early evaluation. This > is fixed in trunk where it evaluates late. > As a work around you can do: > > task dist(type: Zip) { > println .... > doFirst { task -> > task.zipFileZet ... > } Thanks for this workaround. I have used the zip ant task to work around this. I will move back to gradle's zip task type as soon as I have updated gradle. --Peter > - Hans > > -- > Hans Dockter > Gradle Project Manager > http://www.gradle.org > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |