Q:

version numbers in gradle

Anyone know how to get this working in gradle for a SUBPROJECT so that running the left hand size results in the right hand archive name...
gradle assemble -> databus-Developer-Build.zip
gradle -DmyVersion=1.0.2 assemble -> databus-1.0.2.zip
OR
gradle -PmyVersion=1.0.2 assemble -> databas-1.0.2.zip

I have tried and tried with a variable myVersion but it always says it does not exist....and in half the cases, it shouldn't exist because I didn't supply it!!!!!
How to get this working in a subproject?
thanks,
Dean

A:

Add following snippet to allprojects configuration section of root build.gradle:
allprojects {

   if (project.hasProperty('myVersion')) {
     project.version = project.myVersion
   } else {
     project.version = 'Developer-Build'
   }

} 

and than pass your version in command line as -PmyVersion=1.0.2. Tested with rather old Gradle 1.0-milestone-3

