GithubHelp home page GithubHelp logo

wttech / gradle-aem-multi Goto Github PK

View Code? Open in Web Editor NEW
31.0 48.0 18.0 8.74 MB

Example Multi-Module AEM application built by Gradle Build System

Home Page: https://tech.cognifide.com/tag/gradle-aem-plugin

License: Apache License 2.0

Java 24.06% Kotlin 28.28% JavaScript 15.94% HTML 12.98% Shell 4.49% Gherkin 0.86% Groovy 1.00% TypeScript 0.10% Less 0.99% SCSS 11.29%
aem aem-tools adobe-experience-manager cq apache-sling java kotlin gradle gradle-aem-plugin docker

gradle-aem-multi's Introduction

WTT logo

Gradle Status Apache License, Version 2.0, January 2004

Gradle AEM Plugin logo

AEM Multi-Project Example

Description

This project could be used to start developing long-term project based on AEM.

To start developing application/library based on AEM it is recommended to use Gradle AEM Single instead.

Documentation for AEM plugin is available in project Gradle AEM Plugin.

Screenshot

Gradle AEM Multi - Develop task

Table of Contents

Features

Main motivation of this project is to automate all aspects of AEM development and make it a breeze.


Archetyping:

Environment:

Back-end:

Front-end:

Testing:

Maintenance:

Quickstart

  1. Fork project using command:

    git clone https://github.com/wttech/gradle-aem-multi.git && cd gradle-aem-multi && sh gradlew fork

    and specify properties:

    Fork Props Dialog

    and wait until project is forked then enter configured target directory.

  2. Setup user specific project configuration using command:

    sh gradlew props

    and specify properties:

    Fork Props Dialog

  3. Setup local AEM instances with dependencies and AEM dispatcher (see prerequisites) then build application using command:

    sh gradlew environmentHosts
    sh gradlew setup

    and wait till complete AEM environment will be ready to use.

  4. Develop continuously application using command:

    sh gradlew

    which is an alias for:

    sh gradlew develop

    or to just deploy AEM application (without running anything else):

    sh gradlew :app:aem:all:packageDeploy

Prerequisites

Tested on:

  • Java 1.8, 11
  • Gradle 6.7
  • Adobe AEM 6.5
  • Docker 2.4.0.0

Structure

  • app - source code generated from Adobe AEM Archetype 23 and adapted to Gradle / Gradle AEM Plugin,
  • env - resources and configuration related with setting up local AEM instances and AEM dispatcher,
  • test - integration and functional tests requiring full environment setup.

Environment

Project is configured to have local environment which consists of:

  • native AEM instances running on local file system,
  • virtualized Apache HTTP Server with AEM Dispatcher module running on Docker (official httpd image).

Assumptions:

Building

  1. Use command gradlew so that Gradle in version according to project will be downloaded automatically.
  2. Deploy application:
    • Full assembly and run all tests
      • sh gradlew <=> sh gradlew :develop
    • Only assembly package:
      • sh gradlew :app:aem:all:packageDeploy
    • Only single package or bundle:
      • sh gradlew :app:aem:core::bundleInstall,
      • sh gradlew :app:aem:ui.apps:packageDeploy,
      • sh gradlew :app:aem:ui.content:packageDeploy.
  3. Rebuilding front-end only: sh gradlew :app:aem:ui.frontend:build

Tooling

  1. Monitoring errors in logs: sh gradlew instanceTail
  2. Synchronizing JCR content from AEM to local file system: sh gradlew :app:aem:ui.content:packageSync
  3. Interactively updating HTTPD Virtual-Host & AEM Dispatcher configuration: sh gradlew environmentDev
  4. Copying JCR content between AEM instances: sh gradlew instanceRcp -Pinstance.rcp.source=http://user:[email protected]:4502 -Pinstance.rcp.target=local-author -Pinstance.rcp.paths=[/content/example,/content/dam/example]

Tips & tricks

  • To run some task only for subproject, use project path as a prefix, for instance: sh gradlew :app:aem:ui.content:packageDeploy.
  • According to recommendations, Gradle daemon should be:
    • enabled on development environments,
    • disabled on continuous integration environments.
  • To see more descriptive errors or want to skip some tasks, see command line documentation.

Running tests

IntelliJ

Certain unit tests may depend on the results of running gradle tasks. One such example is the testing of OSGi Services using OSGi Mocks where in order to run a test, the SCR metadata must be available for a class. Running a test like this in IntelliJ results in errors because the IDE is not aware of the Bundle plugin.

This can be worked around by configuring IntelliJ to delegate test execution to Gradle. In order to set this up, go to Settings > Build, Execution, Deployment > Gradle > Runner and set your IDE to delegate IDE build/run actions to Gradle. Alternatively, you can use a dropdown menu to use a specific runner or to decide on a test-by-test basis.

Attaching debugger

  1. Execute build with options -Dorg.gradle.debug=true --no-daemon, it will suspend,
  2. Attach debugger on port 5005,
  3. Suspension will be released and build should stop at breakpoint.

Extending build

For defining new tasks directly in build see:

The easiest way to implement custom plugins and use them in project is a technique related with buildSrc/ directory. For more details please read documentation.

gradle-aem-multi's People

Contributors

dawidklos avatar dependabot[bot] avatar devzbysiu avatar mierzwid avatar mmajchrzak avatar pun-ky avatar tomasz-paulus-wttech avatar toniedzwiedz avatar twiernik avatar zajcu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-aem-multi's Issues

Support for KnotX in GAP environment plugin

@Skejven FYI

gradle-aem-multi setups KnotX service side by side with dispatcher

  • it is described in docker-compose.yml - additional KnotX container
  • KnotX is behind Apache and only page requests get forwarded to it
  • there is example content added to multi project thats allows additional rendering to be made by KnotX
  • data source for KnotX will be static files configured and mounted
  • KnotX configuration files would be bind-mounted

GAP support:

  • GAP should be able to perform health checks on KnotX endpoint 8092
  • GAP creates all needed logs and

Docker compose file has incorrect pahts on Windows environments

Hi!
I noticed that paths created in docker-compose.yml file are incorrect on Windows. They contain both backslashes and forward slashes. This leads to docker compose script failure due to "unknown escape character".

In my case the template from docker-compose.yml.peb file:

    volumes:
      - "{{ environment.dockerRootPath }}/distributions/mod_dispatcher.so:/usr/local/apache2/modules/mod_dispatcher.so"
      - "{{ environment.dockerRootPath }}/httpd/cache:/opt/aem/dispatcher/cache"
      - "{{ environment.dockerRootPath }}/httpd/logs:/usr/local/apache2/logs"
      - "{{ environment.dockerConfigPath }}/httpd/conf:/usr/local/apache2/conf"

Gets resolved to:

    volumes:
      - "C:\testwindows\aem\.environment/distributions/mod_dispatcher.so:/usr/local/apache2/modules/mod_dispatcher.so"
      - "C:\testwindows\aem\.environment/httpd/cache:/opt/aem/dispatcher/cache"
      - "C:\testwindows\aem\.environment/httpd/logs:/usr/local/apache2/logs"
      - "C:\testwindows\aem\gradle\environment/httpd/conf:/usr/local/apache2/conf"

Introduce sample backup task

task aemBackup {
   doLast {
      def response = aem.buildPackage(listOf("/content/example"))
      aem.downloadPackage(response.path, project.file("content-backup-${System.currentTimeMilis()}.zip")
   }
}

this will be a little demonstration of writing custom tasks

Plugin not found

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.cognifide.aem.package', artifact: 'com.cognifide.gradle:aem-plugin:4.1.1'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.cognifide.gradle:aem-plugin:4.1.1')
  Searched in the following repositories:
    MavenLocal(file:/C:/Users/x/.m2/repository/)
    BintrayJCenter
    maven(https://plugins.gradle.org/m2/)
    maven2(http://dl.bintray.com/cognifide/maven-public)
    maven3(https://dl.bintray.com/neva-dev/maven-public)

Should I update plugin version to 5.0.0 in settings.gradle?
https://github.com/Cognifide/gradle-aem-multi/blob/master/settings.gradle#L14

Extract dispatcher configuration to project archetypes

Allow users of project archetypes to also fork dispatchers configuration and provide its details specific for the project.

AC

  • when forking gradle-aem-multi
    • dev is asked to provide names for demo and live local domains
    • aemEnvHosts task is configured accordingly
    • reverse mappings are generated
    • invalidation handler is configured
    • whole httpd and dispatchers configuration files are generated
    • basic health checks are generated
    • user can start dispatchers development out of the box

Related #78, #355.

Replication issues

The replication agent on publish in disabled by default which is causing some trouble while working with the instances.

Temporary workflows toggling during package deployment

To prevent renditions being regenerated for every package deploy, it is very often that projects are using such filter:

    <filter root="/content/dam/example-demo" mode="merge">
        <exclude pattern="/content/dam/.*/renditions/.*"/>
        <include pattern="/content/dam/.*/renditions/original(.*)?"/>
    </filter>

This has serious side effect. The images will be never removed and messy images may left on instance(s) unintentionally.

But simply, imagine:

aemDeploy {
    def workflows = [
         "/etc/workflow/launcher/config/update_asset_create"
         "/etc/workflow/launcher/config/update_asset_mod"
    ]
    doFirst {
        aem.sync { it.disableWorkflow(workflows) }
    }
    doLast {
        aem.sync { 
            it.enableWorkflow(workflows)
            // possibility to use any method from: https://github.com/Cognifide/gradle-aem-plugin/blob/master/src/main/kotlin/com/cognifide/gradle/aem/instance/InstanceSync.kt
            // it.restartBundle('x.x.x')
        }
    }
}

aemSync not working

I assume the aemSync gradle task will synchronize the files from the AEM instance with the gradle project files. However, when I run the error that the JCR repositories don't exists, also, I keep getting errors such as

Execution failed for task ':aem:aemSatisfy'.
> Cannot list packages on LocalInstance(httpUrl='http://localhost:4502', user='admin', password='*****', typeName='author', debugPort=14502). Reason: request failed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.