title: How to use Gradle's Manifest API to insert a `MANIFEST.MF` file into the root of a zip file
body: <p>We use the <code>manifest</code> attribute of the java plugin to write <code>MANIFEST.MF</code> files to our <code>jar</code> artifacts.</p>
  
  <p>We also use gradle to build <code>GWT</code> projects and the output we've defined for those projects is a <code>zip</code>. I'd like to include a <code>MANIFEST.MF</code> file in the root of that zip file.</p>
  
  <p>I've tried using a task of <code>type: Jar</code> so I can use its <code>manifest</code> property but the problem, of course, is that the manifest file is written into <code>META-INF/MANIFEST.MF</code>, which I don't want. The reason is that we unzip the archive into the main app and I need to be able to reference the <code>MANIFEST.MF</code> file at runtime for my own nefarious purposes.</p>
  
  <p>So right now the archive looks like this:</p>
  
  <pre><code>/gwtdirectory/
  /gwtdirectory/file1
  /gwtdirectory/file2
  /gwtdirectory/...
  /gwtdirectory/filen
  </code></pre>
  
  <p>And I need it took like this:</p>
  
  <pre><code>/gwtdirectory/
  /gwtdirectory/MANIFEST.MF
  /gwtdirectory/file1
  /gwtdirectory/file2
  /gwtdirectory/...
  /gwtdirectory/filen
  </code></pre>
  
  <p>I've already successfully gotten it to look like:</p>
  
  <pre><code>/gwtdirectory/
  /gwtdirectory/META-INF/MANIFEST.MF
  /gwtdirectory/file1
  /gwtdirectory/file2
  /gwtdirectory/...
  /gwtdirectory/filen
  </code></pre>
  
  <p>Through a definition like:</p>
  
  <pre><code>task pack(type: Jar){
    manifest {
      attributes(...)
    }
    extension = 'zip'
    from gwt.destinationDir
  }
  </code></pre>
  
  <p>The <a href="http://gradle.org/docs/current/javadoc/org/gradle/api/java/archives/Manifest.html#writeTo(java.lang.Object)" rel="noreferrer"><code>writeTo</code></a> method looks mighty promising, except I can't find an implementation of that interface that I can use and I'm trying to avoid writing my own.</p>
  
  <p>Thoughts?</p>