Fork me on GitHub

Configuration

This guide covers the plugin configuration by means of different parameters that are available. End users can follow this guide to configure the plugin to model their use cases flexibly.

Brief details of the different plugin goals and parameters are available on this link. Since most of these parameters are self-explanatory, this guide will focus on resource configuration.

Resource Configuration

A resource is collection of the below three user defined values,

  • templateFilePath : This describes a valid relative or absolute location to a Jinja template based text file. This location must not be a directory, and can end with any extension. It must be ensured that the template file actually exists at the location defined in the plugin configuration before executing the plugin.

    Examples:

    <!-- Absolute Path -->
    <templateFilePath>/path/to/template/a_template.j2</templateFilePath>
    <!-- Relative Path -->
    <templateFilePath>src/main/resources/jinja/template/a_template.j2</templateFilePath>
  • valueFiles : This is a collection of relative or absolute locations of one or more files which contains values that will be substituted into the template provided. In terms of Jinja, these value file(s) help build the context. Each provided value file location must be a valid existing file containing the values in json format.

    Reason to choose JSON format for value files:

    • Type safety of values
    • Unstructured
    • Supports complex types
    • Human readable and popular

    Note: Keys in the value JSON files must not contain . character.

    Examples:

    <valueFiles>
        <param>/path/to/values/value_1.json</param>
        <param>/path/to/values/value_2.json</param>
    </valueFiles>
  • outputFilePath : As the name suggests, this describes a location where the rendered content will be exported as a text file. If a file already exists at the given location then the process will fail unless <overwriteOutput>true</overwriteOutput> is configured. It must be ensured that the build process has appropriate permissions to write to the provided output location.

    Examples:

    <!-- Relative Path -->
    <outputFilePath>src/main/resources/jinja/results/config.json</outputFilePath>
  • dependencyDirs : This is a collection of relative or absolute locations of one or more directories which contains resource files. These resource files can be included/ imported/ extended in templates. This configuration is not mandatory.

    Examples:

    <dependencyDirs>
        <param>${project.basedir}/path/to/dir1/</param>
        <param>/path/to/dir2/</param>
    </dependencyDirs>

Example of a complete resource:

<resourceSet>
    ...

    <resource>
        <templateFilePath>/path/to/template/a_template.j2</templateFilePath>
        <valueFiles>
            <param>/path/to/values/value_1.json</param>
            <param>/path/to/values/value_2.json</param>
        </valueFiles>
        <outputFilePath>src/main/resources/jinja/results/config.json</outputFilePath>
        <dependencyDirs>
            <param>${project.basedir}/path/to/dir1/</param>
            <param>/path/to/dir2/</param>
        </dependencyDirs>
    </resource>

    ...
</resourceSet>

Resource Set

A resourceSet is a collection of one or more resources and can be defined as the snippet below:

    ...

    <plugin>
        <groupId>com.github.chitralverma</groupId>
        <artifactId>jinja-maven-plugin</artifactId>
        <version>${latest.plugin.version}</version>
        <configuration>
            <resourceSet>
                <resource> ... </resource>
                <resource> ... </resource>
            </resourceSet>
        </configuration>
    </plugin>

    ...