title: In a multi-project gradle build how do I pack the content of the subproject-A.war into the subproject-B.jar
body: <p><strong>The problem:</strong> Given the following multi-project <strong><code>gradle</code></strong> build</p>
  
  <pre><code>superproject
      subproject-A -&gt; war
      subproject-B -&gt; jar
  </code></pre>
  
  <p>I am looking for a way to configure <code>subproject-B</code> to unpack the content of the <code>war</code> generated by <code>subproject-A</code> and have the content of the unpacked <code>webapp</code> directory (with classes and resources for a deployment into a container) packed into the application distribution of <code>subproject-B</code> at the root level along with the classes, resources and dependencies of the latter. So the structure of the distribution produced for <code>subproject-B</code> should look like this:</p>
  
  <pre><code>subproject-B-0.1.0
      bin/...
      lib/
          META-INF/ (&lt;-- from B)
          WEB-INF/  (&lt;-- from A.war)
          css/      (&lt;-- from A.war)
          js/       (&lt;-- from A.war)
          *.jar     (code and dependencies of B)
  </code></pre>
  
  <p>The question of copying a resource from A to B was answered <a href="https://stackoverflow.com/questions/27728401/gradle-copy-subproject-resources">here</a>. Here I need to copy the content of a dynamically generated build artifact (and generally it is ok if that is copied into <code>main/resources</code> as the latter will be packed into the <code>jar</code>).</p>
  
  <p><strong>The rationale:</strong> <code>subproject-B</code> is a standalone Java app running <em>tomcat-embed-server</em> with a <em>JavaFX WebView</em> accessing the web app of <code>subproject-B</code> on the <em>localhost</em> turning the otherwise web app into a sort of a standalone desktop app. It is 20 lines of code that run nicely in Eclipse, but seem to pose a packaging challenge for distribution.</p>