The source code of the filter has been fixed, which was somewhat complicated a few months ago, but now there is a standard plug-in in the MOJO project. Now you can do this with the classic plugin declaration.
To filter the source code (for example, if you want to have a constant in your Java code to extract the version of the project or artifactId), you should now use templating-maven-plugin .
Put your code that should be filtered during build in src/main/java-templates , as you usually do in src/main/java for unfiltered sources. Use ${project.version} or any other property coming from the POM in your code.
Just put something like:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>templating-maven-plugin</artifactId> <version>1.0-alpha-3</version> <executions> <execution> <id>filter-src</id> <goals> <goal>filter-sources</goal> </goals> </execution> </executions> </plugin>
Do It:-). The code that you put inside src/main/java-templates is filtered and added to the classpath.
Using is very simple (see example here ).
This reflects the idea of a Maven configuration agreement much better. You basically replace dozens of XML lines and some hacks to do something clean.
Side note: this works great with Eclipse, for example.
Baptiste Mathus Aug 26 '13 at 21:01 2013-08-26 21:01
source share