The bLight Ant task is used to pre-compile templates.
Add the task to your build target.
<typedef resource="blight-ant.xml" classpath="blight-dist/tools/blight-ant-task.jar"/> <blight.compileTemplates outputDir="${basedir}/target/compiled-templates"> <sourceDir>${basedir}/src/main/java</sourceDir> <!-- Include your template packages here --> <package>example.mycompany.myapp</package> </blight.compileTemplates>
To allow on-demand compilation during development, ensure that the task is only run when creating a distribution of your application.
The Ant task can be configured using the parameters below.
Parameter name | Description | Type | Default value | Required |
---|---|---|---|---|
sourceDir | The paths to at least one or more source directories. | Nested element | - | Yes |
package | The fully qualified names of one or more package to compile. | Nested element | - | Yes |
outputDir | The directory to place compiled templates source code. | String | target/compiled-templates | No |
templateMethod | The name of the template method. Only this method will have comments replaced with executable code. | String | execute | No |
commentReplacementPrefix | The prefix to insert before each comment replacement. | String | write( | No |
commentReplacementSuffix | The suffix to insert before each comment replacement. | String | ); | No |
extraCode | Extra code to insert into the compiled template. This will be executed in an initialiser block. | String | setCompiled(true); | No |