How do I modify source code within the context of a Maven plugin? -


i write maven plugin simple find , replace within specific source files during build. possible?

yes, possible. should read guide developing java plugins.

maybe instead of creating new plugin, can use existing one.

example com.google.code.maven-replacer-plugin:replacer:

<plugin>     <groupid>com.google.code.maven-replacer-plugin</groupid>     <artifactid>replacer</artifactid>     <version>1.5.3</version>     <configuration>         <file>file path (example: ${basedir}/src/main/webapp/index.html)</file>         <token>searched text (example: .css)</token>         <value>replacement (example: .min.css)</value>     </configuration> </plugin> 

if want replace xml data, should use cdata sections:

<plugin>     <groupid>com.google.code.maven-replacer-plugin</groupid>     <artifactid>replacer</artifactid>     <version>1.5.3</version>     <configuration>         <file>${basedir}/src/main/webapp/web-inf/web.xml</file>         <token><![cdata[searched text (example: <foo>)]]></token>         <value><![cdata[replacement (example: <foo2>)]]></value>     </configuration> </plugin> 

Comments