jboss - How can I force the Maven EAR plugin to use a context root variable within application.xml? -


i'm using maven ear plugin generate application.xml of ear, contains war.

i want contextroot of war determined @ runtime (this works jboss 7), application.xml should contain this:

<module>   <web>     <web-uri>my.war</web-uri>     <context-root>${my.context.root}</context-root>   </web> </module> 

this works setting system property my.context.root within jboss 7 , configuring jboss 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 editing generated application.xml in ear, works.

however, can't maven write ${my.context.root} context root within application.xml.

i tried first (since nothing filtered, should work):

<configuration>   <modules>     <webmodule>       <groupid>my.group</groupid>       <artifactid>my-war</artifactid>       <contextroot>${my.context.root}</contextroot>     </webmodule>   </modules> </configuration> 

apparently, though filtering defaults false, maven still thinks should use maven property. result ear plugin puts in war's name:

<module>   <web>     <web-uri>my-war.war</web-uri>     <context-root>/my-war</context-root>   </web> </module> 

so tried escaping:

<configuration>   <modules>     <webmodule>       <groupid>my.group</groupid>       <artifactid>my-war</artifactid>       <contextroot>\${my.context.root}</contextroot>     </webmodule>   </modules> </configuration> 

this taken literally:

<module>   <web>     <web-uri>my-war.war</web-uri>     <context-root>\${my.context.root}</context-root>   </web> </module> 

how can maven want? (of course, try hack application.xml using maven replacer plugin, that's ugly...)

thanks hints!

well, since nobody knows better answer, here's how hacked application.xml shape:

<plugin>   <groupid>com.google.code.maven-replacer-plugin</groupid>   <artifactid>replacer</artifactid>   <executions>     <execution>       <id>replace-escaped-context-root</id>       <phase>process-resources</phase>       <goals>         <goal>replace</goal>       </goals>       <configuration>         <file>${project.build.directory}/${project.build.finalname}/meta-inf/application.xml</file>         <regex>false</regex>         <token>\${</token>         <value>${</value>       </configuration>     </execution>   </executions> </plugin>  <plugin>   <artifactid>maven-ear-plugin</artifactid>   <configuration>     <modules>       <webmodule>         <groupid>my.group</groupid>         <artifactid>my-war</artifactid>         <contextroot>\${my.context.root}</contextroot>       </webmodule>     </modules>   </configuration> </plugin> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -