AEM Component Generator

CircleCI

AEM Component Generator is a java project that enables developers to generate the base structure of an AEM component using a JSON configuration file specifying component and dialog properties and other configuration options.

Generated code includes:

How To Use

To see the AEM Component Generator in action, watch this video. Detailed steps for using the generator are found below.

Step 1: Clone the project from github.

Step 2: Update the demo config file (data-config.json) to your company defaults, removing references to NewCo/newco in the project-settings and group values.

Step 3: Build the project by running mvn clean install from the main project folder.

Step 4: Copy the generated component-generator-N.N.jar file (under the target folder) to a location from which you wish to generate AEM component code. Note that code will be generated at a relative path from which the generator is executed, which can be different from where the jar file is located.

Step 5: Copy the data-config.json file from this project to the same location and update with relevant configs for your component.

Step 6: To generate a component, navigate to the main folder of your AEM project and execute the following command. Note that paths specified in project-settings configs (above) will be relative to this location.

$ java -jar <jarfile> <configfile>

Example:

$ java -jar scripts/compgen/component-generator-1.0.jar scripts/compgen/data-config.json

Successful component generation should result in output similar to the following:

[17:57:50.427 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/.content.xml
[17:57:50.441 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/_cq_dialog/.content.xml
[17:57:50.443 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/dialogglobal/.content.xml
[17:57:50.446 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/dialogshared/.content.xml
[17:57:50.447 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/clientlibs/.content.xml
[17:57:50.453 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/clientlibs/site/css/demo-comp.less
[17:57:50.454 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/clientlibs/site/js/demo-comp.js
[17:57:50.456 [INFO ] CommonUtils @93] - Created: ui.apps/src/main/content/jcr_root/apps/newco/components/content/demo-comp/demo-comp.html
[17:57:50.456 [INFO ] ComponentUtils @85] - --------------* Component 'demo-comp' successfully generated *--------------
[17:57:50.476 [INFO ] CommonUtils @93] - Created: core/src/main/java/com/newco/aem/base/core/models/DemoComp.java
[17:57:50.488 [INFO ] CommonUtils @93] - Created: core/src/main/java/com/newco/aem/base/core/models/impl/DemoCompImpl.java
[17:57:50.488 [INFO ] JavaCodeModel @103] - --------------* Sling Model successfully generated *--------------

Contributing

Originally developed and contributed by Bounteous.

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.