1

I am new to Spring MVC, Tiles, and Maven framework and I'm hoping someone will guide me to the right direction to the better practice on updating platform dependent properties. I have a tiles.xml which defines a path to the JSP with a list of JavaScript/CSS imports.

<definition name="abc" extends="base.definition">
  <put-attribute name="imports" value="/WEB-INF/jsp/imports.jsp" /> 
</definition>

During the deployment, I'd like to switch to import minified version of JavaScript/CSS files which are listed in a different JSP file.

<put-attribute name="imports" value="/WEB-INF/jsp/importsMinified.jsp" />

I'm assuming switching the resources or rewriting the content of either this tiles.xml or some sort of properties files which defines environment specific definitions during one of the mvn deployment life cycle. However, I could not find a good example on accomplishing this task. If anyone has experienced this circumstance, could you please advise me what would be a better solution to switching imports? I'm also not sure dividing into two JSP files are better solution or not.

Thank you,

syamashi
  • 31
  • 3
  • I realized a similar post where web.xml could be switched with maven-war-plugin and profiles where is used. http://stackoverflow.com/questions/3298763/maven-customize-web-xml-of-web-app-project So if I want to do the same to tiles.xml, is there a specific tag supported in maven-war-plugin? If not, how do I apply include/exclude to decide which tiles.xml to import on a given profile id? – syamashi Aug 31 '12 at 21:03

1 Answers1

1

I'm not aware of a plugin that will do that for you specifically for Tiles, but you could always have maven filter the file for replacement variables.

For example...

pom.xml

<build>
  <resources>
    <resource>
      <directory>src/main/webapp/WEB-INF</directory>
      <filtering>true</filtering>
      <includes>
        <include>**/tiles.xml</include>
      </includes>
    </resource>
  </resources>
</build>

tiles.xml

<definition name="abc" extends="base.definition">
  <put-attribute name="imports" value="/WEB-INF/jsp/${importsjsp}" /> 
</definition>

From here you have a choice on how to manage the imports.path property:

  • pass a property on the command line mvn -Dimportsjsp=importsMinified.jsp package
  • add a profiles stanza to your pom which has the different values. Call maven passing the -P switch explicitly to choose your profile, or by satisfying the activation requirements.
majorbanzai
  • 551
  • 5
  • 11