blob: 7cb6c0ed151a34156cfc0adb5ee59ac1a42f5c89 [file] [log] [blame]
#set($h1 = '#')
#set($h2 = '##')
#set($h3 = '###')
#set($h4 = '####')
$h2 Usage
$h3 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>
```
$h3 Configuring the HTL Maven Plugin
```
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>htl-maven-plugin</artifactId>
<version>${project.version}</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>
```
$h3 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>${project.version}</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>$context.get("sightly.runtime.version")</version>
<scope>provided</scope>
</dependency>
```