I am porting an ant script to maven, and I am stuck on transforming my web.xml.
My web.xml has the following security constraint set to NONE during development, and to CONFIDENTIAL for the war that is produced for the production server.
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPSOnly</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
I use an XSL script to process web.xml file which is called from ant. I want maven to produce war file where the XSL has been applied to the web.xml and the transformed web.xml is used in the generated war.
I know about the maven XSL plugin and the concept of maven profiles but I am struggling to put it all together and I am not sure what the right maven way is for dealing with situation.
There are many ways you can achieve this. Probably the simplest way is to use maven-antrun-plugin http://maven.apache.org/plugins/maven-antrun-plugin/ and call your existing ant task
Other ways I know is to use a variable / placeholder and Maven filtering (variable substitution), have a look at: http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html
I solved my problem my setting up a prod profile with the pom.xml for the web app, with the following plugins in it. This works for me because when the project is imported into eclipse I really don't want anything fancy to happen and I want everything to work out of the box the developer machine. It is not shown below but I also added a call to NodeJS to build the javascript front end using RequireJS at the generate-sources phase.
The Maven way is to use filtering.
Example below of regular web.xml filtering, without xsl:
If you insist on xsl, you could use Maven xml plugin, working from the base of the example: