Fred Bricon
2014-10-23 17:03:46 UTC
Hello World,
m2e-wtp supports one of Maven's features known as resource filtering for
web [1] and ear [2] projects. Some files contain placeholders that are
replaced by Maven, during a build, with actual values.
Typically, we could have a web.xml file containing
<web-app>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>${jsf.project.stage}</param-value>
</context-param>
...
</web-app>
with filtering enabled and a jsf.project.stage property set to either
Development or Production in pom.xml, that would generate a (filtered)
web.xml in target/m2e-wtp/web-resources/META-INF/ like
<web-app>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
...
</web-app>
A similar mechanism exists to filter resources in EAR projects, where
filtered resources end up under target/m2e-wtp/ear-resources/.
Now, in order to publish the filtered version of these files, instead of
the raw, unfiltered one, m2e-wtp relies on a kind of undocumented behaviour
: in .settings/org.eclipse.wst.common.component, the folder containing
generated files is declared *first* :
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId"
project-version="1.5.0">
<wb-module deploy-name="index-ear">
<wb-resource deploy-path="/" source-path=
"/target/m2e-wtp/ear-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/application" tag
="defaultRootSource"/>
...
</wb-module>
</project-modules>
So when files are duplicated in different wb-resources, the first one found
wins. At least this is true for JBoss, Tomcat, Glassfish server adapters.
Now, it turns out IBM Websphere server adapter does the opposite, last file
wins, which is a problem [3] because unfiltered files end up being served.
Soooo, I would like the WTP to document what is the expected behaviour of
publishing conflicting resources from several wb-modules. I would reaaaally
like to avoid adding one more hack to m2e-wtp to handle these opposite
behaviours.
Which would give us 2 options :
1 - If it's explicitely said first resource wins, then IBM will need to fix
their server adapter.
2 - If the last resource should win, then m2e-wtp and all the adapters for
these open source servers would have to be fixed
Needless to say, I'm strongly in favour of option #1 :-)
I should attend today's WTP call, if anyone wants to discuss that.
Regards,
Fred Bricon
[1]
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
[2]
http://maven.apache.org/plugins/maven-ear-plugin/examples/filtering-sources.html
[1] https://bugs.eclipse.org/437441
m2e-wtp supports one of Maven's features known as resource filtering for
web [1] and ear [2] projects. Some files contain placeholders that are
replaced by Maven, during a build, with actual values.
Typically, we could have a web.xml file containing
<web-app>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>${jsf.project.stage}</param-value>
</context-param>
...
</web-app>
with filtering enabled and a jsf.project.stage property set to either
Development or Production in pom.xml, that would generate a (filtered)
web.xml in target/m2e-wtp/web-resources/META-INF/ like
<web-app>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
...
</web-app>
A similar mechanism exists to filter resources in EAR projects, where
filtered resources end up under target/m2e-wtp/ear-resources/.
Now, in order to publish the filtered version of these files, instead of
the raw, unfiltered one, m2e-wtp relies on a kind of undocumented behaviour
: in .settings/org.eclipse.wst.common.component, the folder containing
generated files is declared *first* :
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId"
project-version="1.5.0">
<wb-module deploy-name="index-ear">
<wb-resource deploy-path="/" source-path=
"/target/m2e-wtp/ear-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/application" tag
="defaultRootSource"/>
...
</wb-module>
</project-modules>
So when files are duplicated in different wb-resources, the first one found
wins. At least this is true for JBoss, Tomcat, Glassfish server adapters.
Now, it turns out IBM Websphere server adapter does the opposite, last file
wins, which is a problem [3] because unfiltered files end up being served.
Soooo, I would like the WTP to document what is the expected behaviour of
publishing conflicting resources from several wb-modules. I would reaaaally
like to avoid adding one more hack to m2e-wtp to handle these opposite
behaviours.
Which would give us 2 options :
1 - If it's explicitely said first resource wins, then IBM will need to fix
their server adapter.
2 - If the last resource should win, then m2e-wtp and all the adapters for
these open source servers would have to be fixed
Needless to say, I'm strongly in favour of option #1 :-)
I should attend today's WTP call, if anyone wants to discuss that.
Regards,
Fred Bricon
[1]
http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html
[2]
http://maven.apache.org/plugins/maven-ear-plugin/examples/filtering-sources.html
[1] https://bugs.eclipse.org/437441
--
"Have you tried turning it off and on again" - The IT Crowd
"Have you tried turning it off and on again" - The IT Crowd