How to manage shared resources for several web apps in Maven AND Eclipse? <p><em>Note: I didn't get any response in the first version of this question, so I modified it to be more generic...</em></p> <p><strong>Context</strong></p> <p>My project is divided into several maven modules and several web-applications. Here is the structure:</p> <pre><code>my-project + pom.xml +-- commons +-- persistence +-- ... +-- web-app-1 +-- web-app-2 +-- ... </code></pre> <p>All the web applications share common resources, such as JS, CSS and images files.</p> <p>Instead of duplicating these resources in each <code>web-app-X</code>, I decided to create another project called <code>web-resources</code>, which is a WAR project. The structure is then the following one:</p> <pre><code>my-project + pom.xml +-- commons +-- persistence +-- ... +-- web-app-1 +-- web-app-2 +-- ... +-- web-resources +-- pom.xml +-- src/main/webapp +-- web.xml (which is almost empty, just need to be present for Maven) +-- web_resources +-- css +-- images +-- javascript </code></pre> <hr/> <p><strong>Maven</strong></p> <p>In Maven 2 (or Maven 3, as I just migrated my project to maven 3.0.2), this configuration is easy to manage as all <code>web-app-X</code> declare <code>web-resources</code> as a dependency:</p> <pre><code>&lt;groupId&gt;foo.bar&lt;/groupId&gt; &lt;artifactId&gt;web-app-1&lt;/artifactId&gt; ... &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;foo.bar&lt;/groupId&gt; &lt;artifactId&gt;web-resources&lt;/artifactId&gt; &lt;version&gt;${preclosing-version}&lt;/version&gt; &lt;type&gt;war&lt;/type&gt; &lt;/dependency&gt; ... </code></pre> <p>So when I build my WAR project, it first get the <code>web-resources.war</code> (built just before), unzip it, and build <em>on top of it</em> the <code>web-app-X</code> web-application. This way, my WAR file will contains also a directory called <code>web-resources/</code> that contains the shared resources.</p> <p>This is the war overlay principle.</p> <p>So on a Maven point of view, everything is fine!</p> <hr/> <p><strong>Eclipse</strong></p> <p>Now, here comes the main problem: having a good Eclipse configuration.</p> <p><em>Question</em>: How can I use my current configuration to be managed correctly by Eclipse? In particular, when I deploy any <code>web-app-X</code> in Tomcat using Eclipse...</p> <p>Note that I want to get the more automatizable (?) configuration, and avoid any manual steps, as this configuration should be used by dozens of developers...</p> <p>For me, the best solution seems to use the <em>linked resources</em> of Eclipse. Thus, I set the following configuration in my <code>web-app-X</code> pom.xml:</p> <pre><code>&lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;wtpversion&gt;1.5&lt;/wtpversion&gt; &lt;linkedResources&gt; &lt;linkedResource&gt; &lt;name&gt;web_resources&lt;/name&gt; &lt;type&gt;2&lt;/type&gt; &lt;location&gt;${project.basedir}\..\web-resources\src\main\webapp\web_resources&lt;/location&gt; &lt;/linkedResource&gt; &lt;/linkedResources&gt; &lt;/configuration&gt; &lt;/plugin&gt; ... </code></pre> <p>When I run the <code>mvn eclipse:eclipse</code> configuration, it adds succesfully this information in my <code>.project</code> file:</p> <pre><code>&lt;projectDescription&gt; ... &lt;linkedResources&gt; &lt;link&gt; &lt;name&gt;web_resources&lt;/name&gt; &lt;type&gt;2&lt;/type&gt; &lt;location&gt;C:\dev\project\web-resources\src\main\webapp\web_resources&lt;/location&gt; &lt;/link&gt; &lt;/linkedResources&gt; &lt;projectDescription&gt; </code></pre> <p>Now, I import my project in Eclipse. Problem: in <code>Project properties &gt; Java Build Path &gt; Source</code>, I don't see the Link Source present. I only see my four Maven default directories (<code>src/main/java</code>, <code>src/main/resources</code>, <code>src/test/java</code> and <code>src/test/resources</code>). What is strange is that when I try to manually add the linked resources, it refuses and says that it already exists...</p> <p>So when I deploy my web application on my Tomcat in Eclipse, it does <em>not</em> deploy the web_resources directory, and thus I don't get the CSS / JS / images deployed. </p> <p>After some tests, it seems that I have to do two modifications:</p> <ol> <li>Add the line <code>&lt;classpathentry kind="src" path="web_resources" output="src/main/webapp/web_resources"/&gt;</code> in my <code>.classpath</code> file;</li> <li>Remove the <code>&lt;project&gt;preclosing-web-resources&lt;/project&gt;</code> in the <code>.project</code> file.</li> </ol> <p>Note that using this configuration, Eclipse will copy (and keep synchronization) the content of web_resources project in my <code>web-app-X/src/main/webapp/web_resources</code>, but this is not a problem (this directory is ignored by the SCM).</p> <p>The only automated solution I found was to create a simple Maven plugin that do the two previous modification, and then run the following command (or use a .bat file):</p> <pre><code>mvn eclipse:clean eclipse:eclipse myEclipsePlugin:eclipse </code></pre> <hr/> <p><strong>Question</strong></p> <ul> <li>Is there a better way to manage such configuration?</li> </ul> <hr/> <p><em>Technical information</em></p> <p>Java 6, Maven 3.0.2, maven eclipse plugin 2.8, Eclipse 3.3.2 (but I can test with newer version of Eclipse), <strong>no</strong> m2eclipse plugin.</p>