Merge Example

Using the HTML Filter Site Maven plugin you can merge HTML files produced outside the normal site generation process with a Velocity template. These files can then be used in your site documentation.

You can run the goal directly by executing:

mvn htmlfilter-site:merge

It is better to bind the goal to the pre-site execution phase, thus:

<plugin>
    <groupId>org.kathrynhuxtable.maven.plugins</groupId>
    <artifactId>htmlfilter-site-maven-plugin</artifactId>
    <version>0.3.4</version>
    <executions>
        <execution>
            <goals>
                <goal>merge</goal>
            </goals>
            <phase>pre-site</phase>
        </execution>
    </executions>
    ...
</plugin>

That way you can simply execute:

mvn site

and the files will be merged before your site documentation is produced.

By default, the source files are found in ${basedir}/site/html and are filtered into ${project.build.directory}/generated-site/resources, which will be copied into your site documentation folder. You can override this by specifying the sourceDirectory or targetDirectory parameter in the configuration section of the plugin, as in the example below, or by specifying the ${htmlfiltersite.sourceDirectory} or ${htmlfiltersite.targetDirectory} expression in your POM or on the command line.

The source and target directories cannot at present be the same.

A Full Example

The following is a complete example of using the HTML Filter Site Maven plugin to merge all the html files in a directory tree.

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.kathrynhuxtable.maven.plugins</groupId>
        <artifactId>htmlfilter-site-maven-plugin</artifactId>
        <version>0.3.4</version>
        <executions>
          <execution>
            <goals>
              <goal>merge</goal>
            </goals>
            <phase>pre-site</phase>
          </execution>
        </executions>
        <configuration>
          <sourceDirectory>${basedir}/src/site/myhtml</sourceDirectory>
          <targetDirectory>${project.build.directory}/generated-site/resources</targetDirectory>
          <filePattern>**/*.html,**/*.html.vm</filePattern>
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>

The example above binds the merge goal to the pre-site phase, causing it to run before the site documentation is created.

The sourceDirectory parameter overrides the default source directory.

The targetDirectory parameter overrides the default target directory.

The filePattern parameter overrides the default pattern matching the files to be converted. The value specified is actually the default value.

Files ending in ".vm" will be filtered for Velocity properties. The .html.vm will be changed to .html in the target directory.

A Sample Velocity Template

See the Velocity template example for a template that can be used to process files. This is the default_site.vm file used by the site plugin.