Giter VIP home page Giter VIP logo

gradle-aem-multi's Introduction

Cognifide logo

Gradle Status Apache License, Version 2.0, January 2004

AEM Multi-Project Example


Gradle AEM Plugin Logo


Screenshot

Gradle AEM Multi Build

Description

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

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

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

Important notice

Gradle AEM Plugin 6.x serie and upper will no longer support Groovy DSL and stands on Kotlin DSL coming with Gradle 5.0.

Documentation for:

Table of Contents

Quickstart

  1. Fork project using command:

    git clone [email protected]:Cognifide/gradle-aem-multi.git && cd gradle-aem-multi && 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:

    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:

    aem/hosts
    gradlew setup

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

  4. Develop continuously application using command:

    gradlew

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

    gradlew :aem:assembly:full:packageDeploy

Prerequisites

Tested on:

  • Java 1.8
  • Gradle 5.4.1
  • Adobe AEM 6.5
  • Docker 2.0.0.3

Structure

Project is divided into subpackages (designed with reinstallabilty on production environments in mind):

  • aem/assembly/full - non-reinstallable complete all-in-one package with application and contents (combination of subpackages: all). Useful to deploy all code by installing single package in a project stage when application is not live.

  • aem/assembly/app - reinstallable assembly package that contains only application code, not content (combination of subpackages: common, sites). Useful to deploy application code only in a project stage when application is live and content should remain untouched on production server.

  • aem/common - OSGi bundle with integrations of libraries needed by other bundles and global AEM extensions (dialogs, form controls etc). Only code unrelated to any site / AEM platform wide.

  • aem/sites - AEM sites module extension consisting of site specific code like: OSGi bundle with business logic, AEM components, templates, design.

  • aem/site.demo - consists of extra AEM pages that presents features of application (useful for testing). Helps application testers and developers in QA/UAT application feature tests.

  • aem/site.live - contains minimal set of pages needed initially to rollout new site(s) using installed application. Helps content authors to start working with application.

Features

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
      • gradlew <=> :develop
    • Only assembly packages:
      • gradlew :aem:assembly:full:packageDeploy
      • gradlew :aem:assembly:app:packageDeploy
    • Only single package: [
      • gradlew :aem:sites:packageDeploy,
      • gradlew :aem:common:packageDeploy,
      • gradlew :aem:site.live:packageDeploy,
      • gradlew :aem:site.demo:packageDeploy.

Build might look complicated, but to make a AEM development a breeze it just covers many things to be done within single task execution like setup or develop. Graphical visualisation of task graph for resetup task:


Resetup task graph


Task setup will:

  • set up AEM instances (author & publish)
  • set up AEM environment (run HTTPD service on Docker) and install AEM dispatcher module
  • build AEM application (compose assembly CRX package from many)
  • migrate AEM application (for projects already deployed on production to upgrade JCR content in case of changed application behavior)
  • clean AEM environment (restart HTTPD service then clean AEM dispatcher caches)
  • check AEM environment (quickly check responsiveness of deployed application)
  • run integration tests
  • run functional tests

To sum up, all things needed by developer are fully automated in one place / Gradle build. Still all separate concerns like running tests, only building application, only running tests, could be used separately by running particular Gradle tasks.

Tips & tricks

  • To run some task only for subproject, use project path as a prefix, for instance: gradlew :aem:site.demo:sync.
  • 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

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

Watchers

James Cloos avatar

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.