Usage
Validating your HTL Scripts
To validate your HTL Scripts you can run the following command:
mvn org.apache.sling:htl-maven-plugin:validate
This assumes the scripts are found in the ${project.build.scriptSourceDirectory}
directory. Alternatively, you can configure the folder using the sourceDirectory
configuration parameter.
The command can be simplified to
mvn htl:validate
if your Maven user settings file provides the following configuration
<pluginGroups> <pluginGroup>org.apache.sling</pluginGroup> </pluginGroups>
Configuring the HTL Maven Plugin
<project> ... <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.sling</groupId> <artifactId>htl-maven-plugin</artifactId> <version>2.0.4-1.4.0</version> <configuration> <!-- put your configurations here --> </configuration> <executions> <execution> <goals> <goal>validate</goal> </goals> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> ... </project>
Generating Java classes from your HTL scripts
Since version 1.1.0 it’s possible to generate Java classes from the project’s HTL scripts. This is useful when you want to identify your script’s Java dependencies or precompile scripts. To do this the following configuration should be applied:
<project> ... <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.sling</groupId> <artifactId>htl-maven-plugin</artifactId> <version>2.0.4-1.4.0</version> <configuration> <!-- put your configurations here --> <failOnWarnings>true</failOnWarnings> <generateJavaClasses>true</generateJavaClasses> </configuration> <executions> <execution> <id>transpile-scripts</id> <goals> <goal>validate</goal> </goals> <phase>generate-sources</phase> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> ... </project>
Additionally, the following dependency is needed as part of your project’s dependency list:
<!-- HTL dependencies needed for the HTL Maven Plugin source code generation --> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.sightly.runtime</artifactId> <version>1.2.6-1.4.0</version> <scope>provided</scope> </dependency>