blob: 6fd614f32387797a0731978019c63efeedf9e7e4 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.8.1 at 2020-06-22
| Rendered using Apache Maven Fluido Skin 1.6
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20200622" />
<meta http-equiv="Content-Language" content="en" />
<title>Apache Sling HTL Maven Plugin &#x2013; Usage</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.6.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.6.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left"><div id="bannerLeft"><h2>Apache Sling HTL Maven Plugin</h2>
</div>
</div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2020-06-22<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 2.0.0-1.4.0</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li><a href="index.html" title="Introduction"><span class="none"></span>Introduction</a> </li>
<li><a href="plugin-info.html" title="Goals"><span class="none"></span>Goals</a> </li>
<li class="active"><a href="#"><span class="none"></span>Usage</a>
</li>
<li class="nav-header">Project Documentation</li>
<li><a href="project-info.html" title="Project Information"><span class="icon-chevron-right"></span>Project Information</a> </li>
<li><a href="project-reports.html" title="Project Reports"><span class="icon-chevron-right"></span>Project Reports</a> </li>
</ul>
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
</div>
</div>
</div>
<div id="bodyColumn" class="span10" >
<div class="section">
<h2><a name="Usage"></a>Usage</h2>
<div class="section">
<h3><a name="Validating_your_HTL_Scripts"></a>Validating your HTL Scripts</h3>
<p>To validate your HTL Scripts you can run the following command:</p>
<div>
<div>
<pre class="source">mvn org.apache.sling:htl-maven-plugin:validate
</pre></div></div>
<p>This assumes the scripts are found in the <tt>${project.build.scriptSourceDirectory}</tt> directory. Alternatively, you can configure the folder using the <tt>sourceDirectory</tt> configuration parameter.</p>
<p>The command can be simplified to</p>
<div>
<div>
<pre class="source">mvn htl:validate
</pre></div></div>
<p>if your Maven user settings file provides the following configuration</p>
<div>
<div>
<pre class="source">&lt;pluginGroups&gt;
&lt;pluginGroup&gt;org.apache.sling&lt;/pluginGroup&gt;
&lt;/pluginGroups&gt;
</pre></div></div>
</div>
<div class="section">
<h3><a name="Configuring_the_HTL_Maven_Plugin"></a>Configuring the HTL Maven Plugin</h3>
<div>
<div>
<pre class="source">&lt;project&gt;
...
&lt;build&gt;
&lt;pluginManagement&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
&lt;artifactId&gt;htl-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;2.0.0-1.4.0&lt;/version&gt;
&lt;configuration&gt;
&lt;!-- put your configurations here --&gt;
&lt;/configuration&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;goals&gt;
&lt;goal&gt;validate&lt;/goal&gt;
&lt;/goals&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/pluginManagement&gt;
&lt;/build&gt;
...
&lt;/project&gt;
</pre></div></div>
</div>
<div class="section">
<h3><a name="Generating_Java_classes_from_your_HTL_scripts"></a>Generating Java classes from your HTL scripts</h3>
<p>Since version 1.1.0 it&#x2019;s possible to generate Java classes from the project&#x2019;s HTL scripts. This is useful when you want to identify your script&#x2019;s Java dependencies. To do this the following configuration should be applied:</p>
<div>
<div>
<pre class="source">&lt;project&gt;
...
&lt;build&gt;
&lt;pluginManagement&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
&lt;artifactId&gt;htl-maven-plugin&lt;/artifactId&gt;
&lt;version&gt;2.0.0-1.4.0&lt;/version&gt;
&lt;configuration&gt;
&lt;!-- put your configurations here --&gt;
&lt;failOnWarnings&gt;true&lt;/failOnWarnings&gt;
&lt;generateJavaClasses&gt;true&lt;/generateJavaClasses&gt;
&lt;/configuration&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;validate-scripts&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;validate&lt;/goal&gt;
&lt;/goals&gt;
&lt;phase&gt;generate-sources&lt;/phase&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/pluginManagement&gt;
&lt;/build&gt;
...
&lt;/project&gt;
</pre></div></div>
<p>Additionally, the following dependencies are required as part of your project&#x2019;s dependencies list:</p>
<div>
<div>
<pre class="source">&lt;!-- HTL dependencies needed for the HTL Maven Plugin source code generation --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
&lt;artifactId&gt;org.apache.sling.scripting.sightly.compiler&lt;/artifactId&gt;
&lt;!-- version 1.0.14 or higher --&gt;
&lt;version&gt;1.0.14&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
&lt;artifactId&gt;org.apache.sling.scripting.sightly.compiler.java&lt;/artifactId&gt;
&lt;!-- version 1.0.16 or higher --&gt;
&lt;version&gt;1.0.16&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
</pre></div></div>
<p>Starting with version 1.2.2 of the <tt>htl-maven-plugin</tt>, only the following dependency is needed as part of your project&#x2019;s dependency list:</p>
<div>
<div>
<pre class="source">&lt;!-- HTL dependencies needed for the HTL Maven Plugin source code generation --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.sling&lt;/groupId&gt;
&lt;artifactId&gt;org.apache.sling.scripting.sightly.runtime&lt;/artifactId&gt;
&lt;version&gt;1.2.0-1.4.0&lt;/version&gt;
&lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
</pre></div></div></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>Copyright &copy;2007&#x2013;2020
<a href="https://www.apache.org/">The Apache Software Foundation</a>.
All rights reserved.</p>
</div>
</div>
</footer>
</body>
</html>