blob: 53fe3bfb62f02c2e477efcd264dac7a7aeb7b142 [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 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>
```
$h3 Configuring the HTL Maven Plugin
```
<project>
...
<build>
<pluginManagement>
<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>
</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. To do this the following configuration should be applied:
```
<project>
...
<build>
<pluginManagement>
<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>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>$context.get("sightly.runtime.version")</version>
<scope>provided</scope>
</dependency>
```