Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This just requires a little advanced use of maven jar &amp; war plugin. </p> <blockquote> <p>First one that has Java classes and some WEB-INF/artifacts</p> </blockquote> <p>Let say this represents the main WAR. You just use maven-war-plugin's Overlays feature. The most basic way is specifying the war dependency :</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;${groupId}&lt;/groupId&gt; &lt;artifactId&gt;${rootArtifactId}-service-impl&lt;/artifactId&gt; &lt;version&gt;${version}&lt;/version&gt; &lt;type&gt;war&lt;/type&gt; &lt;scope&gt;runtime&lt;/scope&gt; &lt;/dependency&gt; </code></pre> <p>and tell maven war plugin to merge assets of this dependency into the main war (where we are now)</p> <pre><code>&lt;plugin&gt; &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;dependentWarExcludes&gt;WEB-INF/web.xml,**/**.class&lt;/dependentWarExcludes&gt; &lt;webResources&gt; &lt;resource&gt; &lt;!-- change if necessary --&gt; &lt;directory&gt;src/main/webapp/WEB-INF&lt;/directory&gt; &lt;filtering&gt;true&lt;/filtering&gt; &lt;targetPath&gt;WEB-INF&lt;/targetPath&gt; &lt;/resource&gt; &lt;/webResources&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>You also include a jar type dependency on the second one (it will be a JAR in <code>WEB-INF/lib/</code>)</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;${groupId}&lt;/groupId&gt; &lt;artifactId&gt;${rootArtifactId}-service&lt;/artifactId&gt; &lt;version&gt;${version}&lt;/version&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/dependency&gt; </code></pre> <p>And you also need to specify dependency on the classes from the third WAR :</p> <pre><code> &lt;dependency&gt; &lt;groupId&gt;${groupId}&lt;/groupId&gt; &lt;artifactId&gt;${rootArtifactId}-service-impl&lt;/artifactId&gt; &lt;version&gt;${version}&lt;/version&gt; &lt;classifier&gt;classes&lt;/classifier&gt; &lt;type&gt;jar&lt;/type&gt; &lt;/dependency&gt; </code></pre> <p>Notice of the classifier, it is necessary because you are specifying 2 dependencies of the same artifact... To make it work, you have to set up jar plugin in the third artifact (war type artifact), regarding the classifier and the fact that you need 2 packages from one artifacts (war &amp; jar):</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;!-- jar goal must be attached to package phase because this artifact is WAR and we need additional package --&gt; &lt;executions&gt; &lt;execution&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;jar&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;!-- classifier must be specified because we specify 2 artifactId dependencies in Portlet module, they differ in type jar/war, but maven requires classifier in this case --&gt; &lt;classifier&gt;classes&lt;/classifier&gt; &lt;includes&gt; &lt;include&gt;**/**.class&lt;/include&gt; &lt;/includes&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload