Generating Java Source Files with JavaPoet

For the most of us developers, generating Java source files is an occasionally happening task and we’re dealing with it e.g. when writing annotation processors, writing tools or interacting with meta-data files. JavaPoet is a nice library to simplify such tasks, offering an intuitive fluent-builder API to generate source files in no time. In the following tutorial I’d like to share a few examples by writing code generators with the help of this library. ...

February 28, 2015 · 5 min · 1035 words · Micha Kops

Filtering Source Files using the Templating Maven Plugin

The Templating Maven Plugin looks useful if one needs to copy and to filter source files in a project e.g. to add property values from the build environment to a class. For a short demonstration I’ve added the following short snippet. Dependencies Only one dependency needed .. simply add the following snippet to your pom.xml <build> <plugins> <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> </plugins> </build> ...

September 3, 2013 · 2 min · 215 words · Micha Kops