Skip to content
bkheadwire edited this page Mar 10, 2017 · 56 revisions

Documentation

https://github.com/headwirecom/aemdc

About

AEM Developer Companion (AEMDC) can be used to quickly create any resource in your AEM maven project from predefined templates using the command line or a gui. Currently it is possible to create:

  • templates
  • components
  • editable template structures (since AEM 6.2) with template types
  • content pages
  • osgi configurations
  • java models
  • java services
  • java servlets
  • java filters

Install

Download the most recently released AEMDC binary ".zip" or "tar.gz" file from (https://github.com/headwirecom/aemdc/releases).

Extract the binary to your tools / "Program Files" directory.

Set the JAVA_HOME and GIT_HOME global ENV variables, as well as the path to AEMDC "bin" folder in the global PATH variable. In Windows, you can set these variables under Systems Properties -> Advanced -> Environmental Variables -> User/System Variables. You can also set the PATH in your cmd/cygwin console like:

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
set GIT_HOME=C:\Program Files\Git
set AEMDC_HOME=C:\Program Files\aemdc
set PATH=%PATH%;%JAVA_HOME%\bin;%GIT_HOME%\bin;%AEMDC_HOME%\bin

Configuration

To configure AEMDC, go to your parent maven project folder (for example /my-aem-project) and run the command:

aemdc config

aemdc-config.jpg

This command creates an AEMDC configuration file with all possible properties and default values. If your maven project was created using the AEM Lazybones Template Tool and there is a layzybones properties file, then some property values from this file

/my-aem-project/.lazybones/stored-params.properties

will be automatically transferred to the AEMDC configuration file.

/my-aem-project/aemdc-config.properties

Below are all of the possible AEMDC configuration properties available in the current version of AEMDC.

Description Property Name Default
AEMDC Files ROOT folder path for AEMDC templates SOURCE_FOLDER ../aemdc-files
AEMDC Files template types folder path SOURCE_TYPES_FOLDER {{SOURCE_FOLDER}}
Target UI project ROOT folder relative path TARGET_UI_FOLDER ui.apps/src/main/content/jcr_root
Target UI project folder name under /apps TARGET_PROJECT_APPS_FOLDER my-aem-project
Target UI project folder name under /conf TARGET_PROJECT_CONF_FOLDER my-aem-project
Target UI project folder name under /etc/designs TARGET_PROJECT_DESIGN_FOLDER my-aem-project
Target apps project path TARGET_PROJECT_ROOT {{TARGET_UI_FOLDER}}/apps/{{TARGET_PROJECT_APPS_FOLDER}}
Target osgi subfolder under TARGET_PROJECT_ROOT TARGET_OSGI_SUBFOLDER ''
Target CORE project ROOT folder relative path TARGET_JAVA_FOLDER core/src/main/java
Target CORE project JAVA package TARGET_JAVA_PACKAGE com.headwire.myaem.core
Target CORE project JAVA package folder path TARGET_JAVA_PACKAGE_FOLDER {{TARGET_JAVA_FOLDER}}/com/headwire/myaem/core
Target CORE project JAVA Model subpackage name TARGET_JAVA_MODEL_SUBPACKAGE model
Extensions for files with placeholders FILES_WITH_PLACEHOLDERS_EXTENSIONS xml,java,html,jsp,js,css,properties
Forbidden template type names FORBIDDEN_TEMPLATE_TYPES .git,.settings,target,help,.idea
Destination dir/file replacement method (WARN, DELETE, MERGE) EXISTING_DESTINATION_RESOURCES_REPLACEMENT MERGE
AEMDC Log level (ALL,TRACE,DEBUG,INFO,WARN,ERROR,OFF) LOG_LEVEL INFO

All properties can be modified according to your needs. A property name can be used as placeholder for defining other property values below it. For example:

TARGET_OSGI_SUBFOLDER=/configuration
TARGET_JAVA_FOLDER=core/src/main/java
TARGET_JAVA_PACKAGE_FOLDER={{TARGET_JAVA_FOLDER}}/com/headwire/myaem/core

Templates setup

AEMDC allows the developer to prepare different project patterns with placeholders such as AEMDC Files (https://github.com/headwirecom/aemdc-files) for your future AEM projects. Developers can then quickly set up a new project structure and its contents using a set of console commands or the AEMDC graphical user interface.

Check out the templates examples from the aemdc-files GitHub repository and use them as the basis for your project:

https://github.com/headwirecom/aemdc-files 

Each template should be structured as follows:

1. Configuration files.

Templates may inherit properties from their parent template type. These properties can be defined here:

/<template-type>/config.properties

Example:

# Source folder
SOURCE_TYPE_FOLDER={{SOURCE_TYPES_FOLDER}}/component

# Target folder
TARGET_TYPE_FOLDER={{TARGET_PROJECT_ROOT}}/components

# Command menu: COPY_DIR,COPY_FILE,COPY_FILES,CREATE_FILE_FROM_RESOURCE,REPLACE_PH,REPLACE_PATH_PH,HELP
COMMAND_MENU=COPY_DIR,REPLACE_PH,REPLACE_PATH_PH

# Available template structure: DIR, FILE
TEMPLATE_STRUCTURE=DIR

# Default placeholders
_jcr\:title={{targetname}}
_jcr\:description={{targetname}}
_targetname={{targetname}}
_componentGroup={{TARGET_PROJECT_APPS_FOLDER}}

Each template may also have its own configuration file which takes precedence over the properties defined in the template type configuration:

/<template-type>/<template-name>/config.properties

Example:

# Source folder
SOURCE_TYPE_FOLDER={{SOURCE_TYPES_FOLDER}}/component/component-js/files/ui.apps/src/main/content/jcr_root/apps/project/components

# Default placeholders
_jcr\:title={{targetname}}Component

There is a special reserved compound template type to execute actions for multiple other templates with one command.

/compound/config.properties
/compound/<template-name>/config.properties

Example:

# Source types and template names
COMPOUND=component:component-model,model:resourcemodel

Below are all of the possible template configuration properties available in the current version of AEMDC.

Description Mandatory Property Name Default Possible values
Template definition folder path yes SOURCE_TYPE_FOLDER '' *
Target folder path yes TARGET_TYPE_FOLDER '' *
Command menu list yes COMMAND_MENU '' COPY_DIR, COPY_FILE, COPY_FILES, CREATE_FILE_FROM_RESOURCE, REPLACE_PH, REPLACE_PATH_PH, HELP
Template structure yes TEMPLATE_STRUCTURE DIR DIR, FILE
Default placeholders no _<placeholder-name> '' *
Compound templates list only for compound type COMPOUND '' <template-type>:<template-name>,...

All properties defined in the aemdc-config.properties, e.g. SOURCE_TYPES_FOLDER, can be used as placeholders in the template configuration. The reserved placeholders below can be also used in the template configuration file:

{{targetCompModel}}
{{runmode}}

The reserved placeholders below can be used in the template file names/paths:

{{targetname}}
{{targetCompModel}}
{{runmode}}
{{java-class}}

The reserved placeholders below can be used inside of template files:

{{ java-class }}
{{ java-package }}
{{ java-interface-package }}

2. Help for command line options and GUI.

Each template type may provide help files to assist in development:

/<template-type>/help/help-type.txt
/<template-type>/help/help-name.txt
/<template-type>/help/help-targetname.txt
/<template-type>/help/help-args.txt
/<template-type>/help/help-gui.txt

Individual templates may also provide their own help files:

/<template-type>/<template-name>/help/help-type.txt
/<template-type>/<template-name>/help/help-name.txt
/<template-type>/<template-name>/help/help-targetname.txt
/<template-type>/<template-name>/help/help-args.txt
/<template-type>/<template-name>/help/help-gui.txt

3. Template files with placeholders.

/<template-type>/<template-name>/files/<path-to-template>/<template-name>/<template files>

For example:

/component/component-js/files/ui.apps/src/main/content/jcr_root/apps/project/components/component-js/.content.xml
/component/component-js/files/ui.apps/src/main/content/jcr_root/apps/project/components/component-js/{{targetname}}.html
/component/component-js/files/ui.apps/src/main/content/jcr_root/apps/project/components/component-js/dialog.xml

How To Use tutorial

AEMDC GUI Tutorial