Mustache Maven Plugin

Maven Plugin for compiling Mustache.js templates using Maven Properties for variables

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.nerdynick
ArtifactId

ArtifactId

mustache-maven-plugin
Last Version

Last Version

2.0.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Mustache Maven Plugin
Maven Plugin for compiling Mustache.js templates using Maven Properties for variables
Project URL

Project URL

https://github.com/nerdynick/mustache-maven-plugin
Source Code Management

Source Code Management

https://github.com/nerdynick/mustache-maven-plugin

Download mustache-maven-plugin

How to add to project

<plugin>
    <groupId>com.nerdynick</groupId>
    <artifactId>mustache-maven-plugin</artifactId>
    <version>2.0.2</version>
</plugin>

Dependencies

compile (2)

Group / Artifact Type Version
com.nerdynick : maven-plugins-template-plugin-core jar
com.github.spullara.mustache.java : compiler jar 0.9.1

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar

test (1)

Group / Artifact Type Version
com.nerdynick : maven-plugins-template-plugin-test jar

Project Modules

There are no modules declared in this project.

mustache-maven-plugin

Maven Plugin for compiling Mustache.js templates using Maven Properties for variables

Build Status

Features

  • Scan a directory of template files and compile
    • Supports optional Includes and Excludes via RegEx pattern match
      • Includes and Excludes can be used together.
      • Includes will take presidence over excludes so that you may include files that may match an exclude pattern.
    • Filenames are preserved on the output
  • Execute on a single file or multiple files
    • Optionally rename the file on the output for single files
  • Compile multiple combinations of the above
  • Most all directive support by the Mustache.java framework are supported
    • Imports are not supported
  • Maven project information imported as variables
    • All properties defined in are added by default
      • All . in property names will be replaced with -
    • Project details are imported
      • ArtifactId - {{project-artifactId}}
      • GroupId - {{project-groupId}}
      • Name - {{project-name}}
      • Description - {{project-description}}

Usage

Basic Plugin Setup

<build>
    <plugins>
        <plugin>
            <groupId>com.nerdynick</groupId>
            <artifactId>mustache-maven-plugin</artifactId>
            <version>${version}</version>
            <configuration>
                <templates>.</templates>
            </configuration>
        </plugin>
    </plugins>
</build>

Template Setups

<templates>

    <!-- Single File -->
    
    <param>
        <outputDir>target/test-harness</outputDir>
        <inputFile>src/test/resources/mustache_test.txt</inputFile>
    </param>
    
    <!-- Single File with name change -->
    
    <param>
        <outputDir>target/test-harness</outputDir>
        <outputName>mustache.txt</outputName>
        <inputFile>src/test/resources/mustache_test.txt</inputFile>
    </param>
    
    <!-- Multiple File -->
    
    <param>
        <outputDir>target/test-harness</outputDir>
        <inputFiles>
            <parma>src/test/resources/mustache_test.txt</param>
            <parma>src/test/resources/mustache_test_2.txt</param>
        </inputFiles>
    </param>
    
    <!-- Directory Scan -->
    
    <param>
        <outputDir>target/test-harness/scan</outputDir>
        <inputDir>
            <directory>src/test/resources/templates</directory>
        </inputDir>
    </param>
    
    <!-- Multiple Directory Scan -->
    
    <param>
        <outputDir>target/test-harness/scan</outputDir>
        <inputDirs>
            <param>
                <directory>src/test/resources/templates</directory>
            </param>
            <param>
                <directory>src/test/resources/other_templates</directory>
            </param>
        </inputDirs>
    </param>
    
    <!-- Directory Scan with Include -->
    
    <param>
        <outputDir>target/test-harness/scan/include</outputDir>
        <inputDir>
            <directory>src/test/resources/templates</directory>
            <includes>
                <param>.+_2.+</param>
            </includes>
        </inputDir>
    </param>
    
    <!-- Directory Scan with Exclude -->
    
    <param>
        <outputDir>target/test-harness/scan/exclude</outputDir>
        <inputDir>
            <directory>src/test/resources/templates</directory>
            <excludes>
                <param>.+_2.+</param>
            </excludes>
        </inputDir>
    </param>
    
    <!-- Combine a number of rules for 1 output dir. -->
    
    <param>
        <outputDir>target/test-harness/scan/exclude</outputDir>
        <outputName>mustache.txt</outputName>
        <inputFile>src/test/resources/mustache_test.txt</inputFile>
        <inputFiles>
            <parma>src/test/resources/mustache_test.txt</param>
            <parma>src/test/resources/mustache_test_2.txt</param>
        </inputFiles>
        <inputDir>
            <directory>src/test/resources/templates</directory>
            <excludes>
                <param>.+_2.+</param>
            </excludes>
        </inputDir>
        <inputDirs>
            <param>
                <directory>src/test/resources/templates</directory>
                <excludes>
                    <param>.+_2.+</param>
                </excludes>
            </param>
            <param>
                <directory>src/test/resources/templates</directory>
                <excludes>
                    <param>.+_2.+</param>
                </excludes>
            </param>
        </inputDirs>
    </param>
</templates>

Versions

Version
2.0.2