在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):wttech/gradle-aem-plugin开源软件地址(OpenSource Url):https://github.com/wttech/gradle-aem-plugin开源编程语言(OpenSource Language):Kotlin 98.8%开源软件介绍(OpenSource Introduction):Table of contentsAboutSwiss army knife for AEM related automation. Incremental build which takes seconds, not minutes. Developer who does not loose focus between build time gaps. Extend freely your build system directly in project. AEM developer - it's time to meet Gradle! You liked or used plugin? Don't forget to star this project on GitHub :) Be inspired by:
Looking for a dedicated version of plugin for Apache Sling? Check out Gradle Sling Plugin! DemoThe example below presents building & deploying AEM package - all handled by Gradle. To review building AEM package by Maven but all the rest handled by Gradle/GAP see Enhancing Maven build section. What is being done above by simply running super easy command
Build is incremental which guarantees optimized time every time regardless of build command used. Only changed parts of application are processed again:
Want to see it in action? Follow here! Features
Gradle AEM Plugin is following strategy convention over configuration. When following built-in conventions about project structure & naming, then only minimal configuration is required. Still all features are fully configurable. Compatibility
Note that since GAP 14.4.22 default Java version used to compile and run AEM instances is Java 11. To instruct GAP to use Java 8, consider setting property: javaSupport.version=8 However since GAP 15.3.3, Java version automatically determined by Quickstart JAR (property below), so that Java support version does not need to be explicitly set up. localInstance.quickstart.jarUrl=https://company-share.com/aem/cq-quicstart-6.5.0.jar Getting startedMost effective way to experience Gradle AEM Plugin is to use:
The only software needed on your machine to start using plugin is Java 8 or newer (also to setup local native AEM instances). Optionally, Docker is needed (when using automatic AEM dispatcher setup). As a build command, it is recommended to use Gradle Wrapper ( LauncherTo use Gradle AEM Plugin it is not needed to have configured a regular Gradle project. By using a single bash command, to be able to:
consider using standalone launcher as it could be the easiest and fastest way to use GAP. PluginsPlugins setupReleased versions of plugin are available on Gradle Plugin Portal](https://plugins.gradle.org/search?term=com.cognifide.aem). Recommended way is to apply plugin using Gradle Plugin Portal and techniques described there. Minimal plugins setupConfiguration assumes:
Then the only thing needed to build CRX package is plugin application (all the rest is obtained automatically by convention): File build.gradle.kts: plugins {
id("com.cognifide.aem.package") version "<version>"
} Complete plugins setupIllustrative configuration below assumes building and deploying on AEM instance(s) via command:
plugins {
id("com.cognifide.environment") version "<version>" // useful to setup AEM dispatcher running on Docker
id("com.cognifide.aem.instance.local") version "<version>" // useful to setup local AEM instances running natively, skip '.local' to work with remote only
id("org.jetbrains.kotlin.jvm") // needed when AEM code written in Kotlin, yes it could be :)
id("com.cognifide.aem.bundle") version "<version>" // needed to built OSGi bundle
id("com.cognifide.aem.package") version "<version>" // needed to build CRX package from JCR content and built OSGi bundle
}
group = "com.company.aem"
version = "1.0.0"
defaultTasks(":instanceProvision", ":packageDeploy")
aem {
`package` { // built CRX package options
contentDir.set(project.file("src/main/content"))
appPath.set(when {
project == project.rootProject -> "/apps/${project.rootProject.name}"
else -> "/apps/${project.rootProject.name}/${projectName}"
})
nodeTypesSync("PRESERVE_AUTO")
validator {
enabled.set(prop.boolean("package.validator.enabled") ?: true)
verbose.set(prop.boolean("package.validator.verbose") ?: true)
planName.set(prop.string("package.validator.plan") ?: "plan.json")
severity("MAJOR")
}
// ...
}
instance { // AEM instances to work with
local("http://localhost:4502") // local-author
local("http://localhost:4503") // local-publish
remote("http://192.168.100.101:4502", "int-author")
remote("http://192.168.100.101:4503", "int-publish")
// etc
http { // allows to customize HTTP connection to AEM instances
connectionTimeout.set(prop.int("instance.http.connectionTimeout") ?: 30000)
connectionRetries.set(prop.boolean("instance.http.connectionRetries") ?: true)
connectionIgnoreSsl.set(prop.boolean("instance.http.connectionIgnoreSsl") ?: true)
proxyHost.set(prop.string("instance.http.proxyHost"))
proxyPort.set(prop.int("instance.http.proxyPort"))
proxyScheme.set(prop.string("instance.http.proxyScheme"))
}
provisioner { // configuring AEM instances in various circumstances (e.g only once)
enableCrxDe()
deployPackage("com.adobe.cq:core.wcm.components.all:2.11.0@zip")
deployPackage("com.neva.felix:search-webconsole-plugin:1.3.0")
step("setup-replication-author") {
condition { once() && instance.author }
sync {
repository {
save("/etc/replication/agents.author/publish/jcr:content", mapOf(
"enabled" to true,
"userId" to instance.user,
"transportUri" to "http://localhost:4503/bin/receive?sling:authRequestLogin=1",
"transportUser" to instance.user,
"transportPassword" to instance.password
))
}
}
}
// ...
}
}
localInstance { // config for AEM instances to be created on local file system
quickstart {
jarUrl.set(prop.string("localInstance.quickstart.jarUrl"))
licenseUrl.set(prop.string("localInstance.quickstart.licenseUrl"))
}
backup {
uploadUrl.set(prop.string("localInstance.backup.uploadUrl"))
downloadUrl.set(prop.string("localInstance.backup.downloadUrl"))
}
install { // CRX packages and OSGi bundles to be pre-installed on created AEM instances
files(
"http://.../package.zip" // CRX package downloaded over HTTP
"group:name:version" // OSGi bundle from Maven repository
)
}
init { // hook called once in scope of instance just created and up first time
logger.info("Initializing instance '$name'")
sync {
// ...
}
}
rootDir.set(prop.string("localInstance.rootDir"))
// ...
}
tasks {
jar {
bundle {
// customizing OSGi bundle manifest
description = "Example application built by GAP"
docUrl = "https://github.com/wttech/gradle-aem-example"
exportPackage("com.company.example.aem.*")
slingModelPackages = "com.company.example.aem"
// for checking OSGi component health on runtime
javaPackage.set("com.company.example.aem")
// other / more advanced options
importPackageWildcard.set(true)
// ...
}
}
packageCompose { // customizing built CRX package
nestPackageProject(":core")
nestPackageProject(":config")
archiveBaseName.set("example-for-changing-zip-name")
vaultDefinition { // place for overriding CRX Package / Vault properties, defining hooks
// ...
}
}
// ... and all other tasks
}
} To see all available options and actual documentation, please follow to:
Plugins documentationGradle AEM Plugin to be more concise is now more like set of plugins. Each plugin has its own documentation:
How to'sSet AEM configuration properly for all / concrete project(s)Common configuration like root of content for JCR package, should be defined in import com.cognifide.gradle.aem.bundle.tasks.bundle
allprojects {
plugins.withId("com.cognifide.aem.common") {
configure<AemExtension> {
`package` {
contentDir.set(project.file("src/main/aem")) // overrides default dir named 'content'
}
}
}
plugins.withId("com.cognifide.aem.bundle") {
tasks {
jar {
bundle {
category = "example"
vendor = "Company"
}
}
}
dependencies {
"compileOnly"("com.adobe.aem:uber-jar:${Build.AEM_VERSION}:apis") // and more
}
}
} For instance, subproject import com.cognifide.gradle.aem.bundle.tasks.bundle
plugins {
id("com.cognifide.aem.bundle")
}
tasks {
jar {
bundle {
javaPackage.set("com.company.example.aem.core")
}
}
packageCompose {
nestPackageProject(':content')
archiveBaseName.set("example-core")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
} Understand why there are one or two plugins to be applied in build scriptGradle AEM Plugin assumes separation of 5 plugins to properly fit into Gradle tasks structure correctly. Most often, Gradle commands are being launched from project root and tasks are being run by their name e.g Work effectively on start and daily basisInitially, to create fully configured local AEM instances simply run command
Customize convention for CRX package and OSGi bundle names and pathsBecause of bug related with regresion introduced in Gradle 5.1, there are some difficulties with setting archives base names. AEM Plugin is overriding default Gradle convention for not only having project name in archive base name, but also to having prefix - root project name when project is one of subprojects (multi-project build case as in Gradle AEM Multi). However overriding this convention might not be trivial and is not recommended as of AEM Plugin in most cases proposes good enough battle-tested convention. Still, if it is really needed to be done - setting customized name for CRX packages and OSGi bundles built, use snippet: subprojects {
afterEvaluate {
tasks {
withType<AbstractArchiveTask>().configureEach {
archiveBaseName.set("acme-${project.name}")
}
}
}
} Then, also common case is to customize paths in which OSGi bundles should be placed in built CRX package. As practice shows up, mostly desired snippet to be used is: subprojects {
plugins.withId("com.cognifide.aem.package") {
configure<AemExtension> {
`package` {
installPath.set("/apps/acme/${project.name}/install")
}
}
}
} Target individual instances when running tasksThe ability to perform tasks against individual instances is provided by the Common Plugin, which comes with instance filtering. Read more on instance filtering if you're looking for information on:
Building
TestingLocal instance testsPart of functional tests are using real AEM to ensure correctness of features. As of AEM is not available to the public, it needs to be provided externally from remote server or by providing local file path. AEM files available locally: gradlew functionalTest \
-DlocalInstance.jarUrl=/Users/krystian.panek/Servers/aem65/cq-quickstart-6.5.0.jar \
-DlocalInstance.licenseUrl=/Users/krystian.panek/Servers/aem65/license.properties AEM files hosted externally: gradlew functionalTest \
-DlocalInstance.jarUrl=https://my-company.com/cq/6.5.0/cq-quickstart-6.5.0.jar \
-DlocalInstance.licenseUrl=https://my-company.com/cq/6.5.0/license.properties \
-DfileTransfer.user=foo \
-DfileTransfer.password=pass Debugging testsTo debug plugin source code while:
Gradle will stop for a moment and wait until remote connection at port 5005 will be established from e.g IDE. ContributingIssues reported or pull requests created will be very appreciated.
LicenseGradle AEM Plugin is licensed under the Apache License, Version 2.0 (the "License") |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论