title: how to get version number or something else into my zip archive in gradle
body: <p>EDIT:
  I am trying to run these two commands and get these results in a gradle subproject...</p>
  
  <pre><code>gradle assemble -&gt; databus-Developer-Build.zip
  gradle -DmyVersion=1.0.2 -&gt; databus-1.0.2.zip
  </code></pre>
  
  <p>Currently, my output is databus-null.zip IF I use $version instead of $myVersion.  When using $MyVersion, I get the error "myVersion is not a property on that task".  :( :(.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>So, trying out the first answer completely failed with "Could not find property $myVersion on task ':webserver:myZip"</p>
  
  <p>NOTE: I am trying to do this in a subproject right now.  Here is the subproject gradle code...</p>
  
  <pre><code>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 -&gt;
          if (taskGraph.hasTask(assemble) &amp;&amp; myVersion == null) {
              myVersion = 'Developer-Build'
          }
      }
  }
  </code></pre>
  
  <p>thanks,
  Dean</p>