The bLight Maven plugin is used to pre-compile templates.
Add the plugin to the build plugins section of your pom.xml.
<plugin> <groupId>com.aleax</groupId> <artifactId>blight-maven-plugin</artifactId> <version>1.0.0</version> <configuration> <packageNames> <!-- Include your template packages here --> <param>example.mycompany.myapp.packages</param> </packageNames> </configuration> <executions> <execution> <goals> <goal>compileTemplates</goal> </goals> </execution> </executions> </plugin>
By default, the plugin is executed in Maven's process-classes phase, after the main application classes have been compiled. To allow on-demand compilation during development, add <phase>prepare-package</phase> to the executionelement.
The bLight Maven plugin can be configured using the parameters below. Note: Only the packageNames parameter is required, the rest are optional.
Parameter name | Description | Default value | Required |
---|---|---|---|
packageNames | A list of package names to compile. | - | Yes |
Source | The Java source level | Default Maven compiler source level | No |
Target | The Java target level | Default Maven compiler target level | No |
compiledTemplateDir | The directory to place compiled templates source code. | target/compiled-templates | No |
templateMethod | The name of the template method. Only this method will have comments replaced with executable code. | execute | No |
commentReplacementPrefix | The prefix to insert before each comment replacement. | write( | No |
commentReplacementSuffix | The suffix to insert before each comment replacement. | ); | No |
extraCode | Extra code to insert into the compiled template. This will be executed in an initialiser block. | setCompiled(true); | No |