我正在使用 Maven EAR 插件来生成application.xml
我的 EAR,其中包含一个 WAR。
我希望contextRoot
在运行时确定 WAR(这要归功于 JBoss AS 7),所以application.xml
应该包含如下内容:
<module>
<web>
<web-uri>my.war</web-uri>
<context-root>${my.context.root}</context-root>
</web>
</module>
这通过my.context.root
在 JBoss AS 7 中设置系统属性并配置 JBoss 以替换 XML 描述符文件中的变量来工作:
<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>
如果我通过编辑application.xml
EAR 中生成的内容来做到这一点,它就可以工作。
但是,我无法让 Maven${my.context.root}
写入application.xml
.
我首先尝试了这个(因为没有过滤,它应该可以工作):
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
显然,即使filtering
默认为false
,Maven 仍然认为它应该使用它作为 Maven 属性。结果是 EAR 插件只输入了 WAR 的名称:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>/my-war</context-root>
</web>
</module>
所以我尝试逃避:
<configuration>
<modules>
<webModule>
<groupId>my.group</groupId>
<artifactId>my-war</artifactId>
<contextRoot>\${my.context.root}</contextRoot>
</webModule>
</modules>
</configuration>
然后按字面意思理解:
<module>
<web>
<web-uri>my-war.war</web-uri>
<context-root>\${my.context.root}</context-root>
</web>
</module>
我怎样才能让 Maven 做我想做的事?(当然,我可以尝试application.xml
使用 Maven 替换插件来破解,但这很难看......)
感谢您的任何提示!