Articles Tagged ‘source’

Generating Java Source Files with JavaPoet

Saturday, February 28th, 2015

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.


Filtering Source Files using the Templating Maven Plugin

Tuesday, September 3rd, 2013

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.