Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 3.07 KB

README.md

File metadata and controls

56 lines (44 loc) · 3.07 KB

FreeMarker Maven Plugin

GitHub Workflow Status (branch) Maven Central GitHub

Maven Plugin for using the FreeMarker template engine in builds

Usage

To use the plugin, place the following plugin element into your pom.xml under project/build/plugins (adjust the configuration element to your needs, see below):

<project>

    <build>
    
        <plugins>
        
            <plugin>
                <groupId>de.steffendingel</groupId>
                <artifactId>freemarker-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>freemarker</goal>
                        </goals>
                        <configuration>
                            <templateDirectory>${project.basedir}/src/main/freemarker</templateDirectory>
                            <templateName>simple-template.ftl</templateName>
                            <inputFiles>
                                <directory>${project.basedir}/src/main/model</directory>
                            </inputFiles>
                            <outputDirectory>${project.build.directory}/html</outputDirectory>
                            <outputExtension>html</outputExtension>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>

</project>

Currently, the plugin supports only one goal freemarker:freemarker which applies a FreeMarker template to a set of JSON input files, writing one output file for each input file. By default, this goal binds to the Maven lifecylce phase generate-resources.

The goal supports the following configuration parameters:

  • templateDirectory (optional, default is ${project.basedir}/src/main/freemarker): Directory where the FreeMarker templates are located.
  • templateName (required): Name of the FreeMarker template file (including the extension).
  • inputFiles (required): Set of JSON input files (models) for FreeMarker. The path of each file relative to the base directory of the file set is used to determine the output file path.
  • outputDirectory (required): Directory to write the output files to. The output files are written in the same structure as the input files are found in the inputFiles file set.
  • outputExtension (required): File extension of the output file (without the dot).