To validate your HTL Scripts you can run the following command:
mvn org.apache.sling:htl-maven-plugin:validate
This assumes you’ve configured the ${project.build.sourceDirectory} setting.
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>
<project> ... <build> <pluginManagement> <plugin> <groupId>org.apache.sling</groupId> <artifactId>htl-maven-plugin</artifactId> <version>1.3.0-1.4.0/version> <configuration> <!-- put your configurations here --> </configuration> <executions> <execution> <goals> <goal>validate</goal> </goals> </execution> </executions> </plugin> </pluginManagement> </build> ... </project>
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. To do this the following configuration should be applied:
<project> ... <build> <pluginManagement> <plugin> <groupId>org.apache.sling</groupId> <artifactId>htl-maven-plugin</artifactId> <version>1.3.0-1.4.0/version> <configuration> <!-- put your configurations here --> <failOnWarnings>true</failOnWarnings> <generateJavaClasses>true</generateJavaClasses> </configuration> <executions> <execution> <id>validate-scripts</id> <goals> <goal>validate</goal> </goals> <phase>generate-sources</phase> </execution> </executions> </plugin> </pluginManagement> </build> ... </project>
Additionally, the following dependencies are required as part of your project’s dependencies list:
<!-- HTL dependencies needed for the HTL Maven Plugin source code generation --> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.sightly.compiler</artifactId> <!-- version 1.0.14 or higher --> <version>1.0.14</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.sightly.compiler.java</artifactId> <!-- version 1.0.16 or higher --> <version>1.0.16</version> <scope>provided</scope> </dependency>
Starting with version 1.2.2 of the htl-maven-plugin, only 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.1.1-1.4.0-SNAPSHOT</version> <scope>provided</scope> </dependency>