I'm trying to leverage the useful overlay feature of the maven-war-plugin.
In other words, I have a template (packaged as WAR file, template-0.0.1.war
) containing tag files, css, js and images.
When I set template-0.0.1.war
as a dependency of the myApp project I get a final myApp.war
containing all the files of template-0.0.1.war
overwritten by those with the same path in the myApp project.
This is the behavior I want.
However, I need to introduce in the pom.xml
of myApp a configuration of the maven-war-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>../path/to/another/dir</directory>
</resource>
</webResources>
</configuration>
</plugin>
As soon as I introduce such a configuration of the plugin, I obtain the final myApp.war
with all the files from both template-0.0.1.war
and myApp project but the files of template-0.0.1.war
overwrite those with the same path in the myApp project.
This behavior is exactly the opposite of what I expect.
Can someone tell me where I'm wrong?
Thanks in advance.
Edit after the solution was found:
The described issue is due to the concurrency of different actions: the WAR overlay (which works correctly) and the external webResources
.
In fact, the external webResources
tag points to the template project directory: totally unuseful for Maven, but indispensable to "fool" the m2e eclipse plugin and let it see the custom tags contained in the template.
The solution I have adopted is to introduce 2 different profiles in the plugin section of my pom.xml
: the first one called "eclipse" in which I inserted the maven-war-plugin
with the webResources
and a second profile (called "standard" and activated by default) without the maven-war-plugin
.