AEM as a Cloud Service supports the deployment of the ui.apps
component scripts as precompiled bundled scripts. This allows developers to precompile their scripts at build-time and package them as OSGi bundles.
Deploying your scripts as precompiled bundled scripts has the following benefits:
Import-Package
and Export-Package
bundle headerssling:resourceSuperType
) and delegation to other resource types (via HTL’s data-sly-resource
block element or via the sling:include
JSP tag, for example) can be mapped via the bundle’s meta-dataThe htl-maven-plugin
can validate the syntax of HTL scripts, but it can also be used to transpile the HTL scripts into Java classes. These are then added to your Maven project’s generated-sources
folder and picked-up by the maven-compiler-plugin
.
The bnd-maven-plugin
can be added to generate the OSGi bundle’s metadata for Java API imports.
The OSGi framework provides a powerful way of defining Requirements and Capabilities to express contracts between various components. These are described via meta-data and enforced at runtime. Bundled scripts use this mechanism to express both their inheritance relationships (sling:resourceSuperType
), as well as delegation (including other resource types in the rendering process).
The bnd
plugin from the scriptingbundle-maven-plugin project can be used to extract the Requirements and Capabilities corresponding to the scripts provided by the ui.apps
content package.
Starting with version 31, the AEM Project Archetype can be used to correctly set up an AEM as a Cloud Service project to use precompiled bundled scripts. In addition, the AEM Project Archetype configures the AEM as a Cloud Service SDK Build Analyzer Maven Plugin to validate the Java package-level as well as script-level dependencies.