What's the best approach to customising a suplpied plug-in? I assume that we don't want to change the supplied plug-ins as the changes will be lost when we upgrade
If you can, create a "maven.xml" file in your directory (same directory where project.xml is) and add "postGoal" or "preGoal" tags to have your behavior happen before or after some specific goal in the plug-in you want to modify.
Below is an example of a maven.xml file I use on a lot of projects. It is how we've solved the problem that Maven doesn't give filtering (a la ANT) any place in the official model. Hopefully it'll give you an idea of how to do similar things yourself. The "preGoal" to "war:init" copies files from a static directory (src/webapp) into a property-defined directory (maven.war.src), and if they aren't JSPs, it puts them through an ant filtering process. We use this to change configuration values between deploy targets (local, dev server, staging server, production server).
The other is a postGoal to "java:compile" which also deals with our pattern of "target-specific" resources, although in this case it handles the filtering of classpath resources.
This definitely wasn't written for redistribution, so you may have to deal with certain hard-coded expectations about where things will be in your project directory structure, etc. But it should give a general idea of how you can make your own maven.xml file.
Joe
<?xml version="1.0"?> <project xmlns:j="jelly:core" xmlns:license="license" xmlns:util="jelly:util" xmlns:ant="jelly:ant">
<!-- - MAVEN PRE-GOAL: 'war:init' - Copy and filter web-inf values --> <preGoal name="war:init"> <ant:available property="maven.target.filters.available" file="${basedir}/conf/filters-${deploy.target}.properties" />
<j:set var="jgsi.war.src"
value="${pom.getPluginContext('maven-war-plugin').getVariable('maven.war.src')}" />
<ant:copy todir="${jgsi.war.src}" overwrite="true"> <ant:fileset dir="${basedir}/src/webapp"> <excludes> <exclude>**/*.jsp</exclude> </excludes> </ant:fileset>
<j:if test="${maven.target.filters.available}"> <ant:filterset> <ant:filtersfile file="${basedir}/conf/filters-${deploy.target}.properties" /> </ant:filterset> </j:if> </ant:copy>
<ant:echo>Copying JSPs -- no filtering</ant:echo>
<ant:copy todir="${jgsi.war.src}" overwrite="false"> <ant:fileset dir="${basedir}/src/webapp"> <includes> <include>**/*.jsp</include> </includes> </ant:fileset> </ant:copy> </preGoal>
<!-- - MAVEN POST-GOAL: 'java:compile' - Copy resources --> <postGoal name="java:compile"> <attainGoal name="target:copy-resources" /> </postGoal>
<!-- - MAVEN GOAL: 'target:copy-resources' - copy and filter resource according to deploy targets --> <goal name="target:copy-resources" description="copy and filter resource according to deploy targets"> <ant:echo>copy target-specific resources - ${deploy.target}</ant:echo>
<ant:available property="jgsi.resource.dir.available" file="${basedir}/src/resource" />
<ant:available property="jgsi.resource.target.dir.available" file="${basedir}/src/resource-${deploy.target}" />
<ant:available property="jgsi.resource.target.filters.available" file="${basedir}/conf/filters-${deploy.target}.properties" />
<ant:condition property="jgsi.any.resources" value="true"> <ant:or> <ant:istrue value="${jgsi.resource.dir.available}" />
<ant:istrue value="${jgsi.resource.target.dir.available}" /> </ant:or> </ant:condition>
<j:if test="${jgsi.any.resources}"> <ant:copy todir="${maven.build.dest}" overwrite="true"> <j:if test="${jgsi.resource.target.filters.available}"> <ant:filterset> <ant:filtersfile file="${basedir}/conf/filters-${deploy.target}.properties" /> </ant:filterset> </j:if>
<j:if test="${jgsi.resource.dir.available}"> <ant:fileset dir="${basedir}/src/resource" /> </j:if>
<j:if test="${jgsi.resource.target.dir.available}"> <ant:fileset dir="${basedir}/src/resource-${deploy.target}" /> </j:if> </ant:copy> </j:if> </goal> </project>
--
--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "If nature worked that way, the universe would crash all the time." --Jaron Lanier
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]