I'm using the Maven EAR plugin to generate the application.xml
of my EAR, which contains a WAR.
I want the contextRoot
of that WAR to be determined at runtime (this works thanks to JBoss AS 7), so the application.xml
should contain something like this:
<module>
<web>
<web-uri>my.war</web-uri>
<context-root>${my.context.root}</context-root>
</web>
</module>
This works by setting the System Property my.context.root
within JBoss AS 7 and configuring JBoss to replace variables within XML descriptor files:
<system-properties>
<property name="my.context.root" value="/foo"/>
</system-properties>
<subsystem xmlns="urn:jboss:domain:ee:1.1">
<spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
<jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>
If I do this by editing the generated application.xml
in the EAR, it works.
However, I can't get Maven to write ${my.context.root}
into the context root within application.xml
.
I tried this first (since nothing is filtered, it should work):
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
Apparently, even though filtering
defaults to false
, Maven still thinks it should use this as Maven property. The result is that the EAR plugin just puts in the WAR's name:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>/my-war</context-root>
</web>
</module>
So I tried escaping:
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>\${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
This is then taken literally:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>\${my.context.root}</context-root>
</web>
</module>
How can I get Maven to do what I want? (Of course, I could try to hack application.xml
by using the Maven replacer plugin, but that's ugly...)
Thanks for any hints!