AEM Developer Tools for Eclipse

Overview

The AEM Developer Tools for Eclipse is a Eclipse plugin based on the Eclipse plugin for Apache Sling released under the Apache License 2.

It offers several features that make AEM development easier:

  • Seamless integration with AEM instances through Eclipse Server Connector
  • Synchronization for both content and OSGi bundles
  • Debugging support with code hot-swapping capability
  • Simple bootstrap of AEM projects via a specific Project Creation Wizard
  • Easy editing of JCR properties

Requirements

Before using the AEM Developer Tools, you need to:

NOTE

On macOS, you need to right-click on Eclipse.app and then select Show Package Contents in order to find your eclipse.ini.

How to Install the AEM Developer Tools for Eclipse

Once you have fulfilled the requirements above, you can install the plugin as follows:

  1. Open the AEM Developer Tools Web Site.

  2. Copy the Installation Link.

    Note that alternatively you can download an archive instead of using the installation link. This allows offline installation but you will miss automatic update notifications this way.

  3. In Eclipse, open the Help menu.

  4. Click Install New Software.

  5. Click Add….

  6. In Name enter AEM Developer Tools.

  7. In Location copy the installation URL.

  8. Click Add.

  9. Check both AEM and Sling plugins.

  10. Click Next.

  11. In the Install Details window, click Next again.

  12. Accept the license agreements and click Finish.

  13. Click RestartNow in order to restart Eclipse.

The AEM Perspective

In Eclipse a Perspective determines the actions and views available within a window and enable task-oriented interaction with resources in Eclipse. For more details about Perspective, see the Eclipse documentation.

The AEM Development Tools for Eclipse provides an AEM Perspective that offers you full control over your AEM projects and instances. To open the AEM Perspective:

  1. From the Eclipse menu bar select Window -> Perspective -> Open Perspective -> Other.
  2. Select AEM in the dialog and click Open.

The AEM perspective in Eclipse

Sample Multi-Module Project

The AEM Developer Tools for Eclipse comes with a sample, multi-module project that helps you quickly get up to speed with a project setup in Eclipse, as well as serving as a best-practice guide to several AEM features. Learn more about the Project Archetype.

Follow these steps to create the sample project:

  1. In the File > New > Project menu, browse to the AEM section and select AEM Sample Multi-Module Project.

    AEM Sample Multi-Module Project

  2. Click Next.

    NOTE

    This step might take a moment since m2eclipse needs to scan the archetype catalogs.

  3. Choose com.adobe.granite.archetypes : sample-project-archetype : <highest-number> from the menu, then click Next.

    Select archetype version

  4. Provide the following fields for the sample project:

    • Name
    • Group Id
    • Artifact Id
    • appId - You may need to expand the Advanced options to set this value.
    • appTitle - You may need to expand the Advanced options to set this value.
    • Package - You may need to expand the Advanced options to set this value.

    Define archetype properties

  5. Click Next.

  6. You then configure an AEM server to which Eclipse will connect.

    In order to use the debugger feature, you need to have started AEM in debug mode - which can be achieved eg by adding the following to the command line:

        -nofork -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10123
    

    Connect to AEM server

  7. Click Finish. The project structure is created.

    NOTE

    On a fresh installation (more specifically, when maven dependencies have never been downloaded) you might get the project created with errors. In this case please follow the procedure describe in Resolving Invalid Project Definition.

How To Import Existing Projects

You can use the New Project feature to create the right structure for you:

  1. Follow the instructions to create a Sample Multi-Module Project and you will have the following projects created for you, which will allow healthy separation of concerns:

    • PROJECT.ui.apps for /apps and /etc content
    • PROJECT.ui.content for /content that is authored
    • PROJECT.core for Java bundles (these will become interesting as soon as you want to add Java code)
    • PROJECT.it.launcher and PROJECT.it.tests for integration tests
  2. Replace the content of your PROJECT.ui.apps project with the apps and etc folders of your package:

    1. In the Project Explorer panel, unfold PROJECT.ui.apps > src > main > content > jcr_root > apps.
    2. Right-click on the apps folder and choose Show In > System Explorer.
    3. Delete the apps and etc folders that you should now see and place here the apps and etc folders of your content package.
    4. In Eclipse, right-click on the PROJECT.ui.apps project and choose Refresh.
  3. Then do the same for the PROJECT.ui.content and replace its content folder with the one of your package:

    1. In the Project Explorer panel, unfold PROJECT.ui.content > src > main > content > jcr_root > content.
    2. Right-click on the deeper content folder and choose Show In -> System Explorer.
    3. Delete the content folder that you should now see and place here the content folder of your content package.
    4. In Eclipse, right-click on the PROJECT.ui.content project and choose Refresh.
  4. Now you have to update the filter.xml files of these two projects to correspond to the content of your content package. For that, open the META-INF/vault/filter.xml file of your content package in a separate text/code editor.

    • This is an example of how your filter.xml file can look:
    <?xml version="1.0" encoding="UTF-8"?>
    <workspaceFilter version="1.0">
        <filter root="/apps/foo"/>
        <filter root="/apps/foundation/components/bar"/>
        <filter root="/etc/designs/foo"/>
        <filter root="/content/foo"/>
        <filter root="/content/dam/foo"/>
        <filter root="/content/usergenerated/content/foo"/>
    </workspaceFilter>
    
  5. As for the content of your package that was split into two projects, you’ll also have to split these filter rules into two and update accordingly the filter.xml files of the two projects.

    1. In Eclipse, open PROJECT.ui.apps/src/main/content/META-INF/filter.xml.

    2. Replace the content of the <workspaceFilter> element with the rules of your package that start with /apps and /etc

      • For example:

        <?xml version="1.0" encoding="UTF-8"?>
        <workspaceFilter version="1.0">
           <filter root="/apps/foo"/>
           <filter root="/apps/foundation/components/bar"/>
           <filter root="/etc/designs/foo"/>
        </workspaceFilter>
        
    3. Then open PROJECT.ui.content/src/main/content/META-INF/filter.xml.

    4. Replace the rules with the ones of your package that start with /content.

      • For example:

        <?xml version="1.0" encoding="UTF-8"?>
        <workspaceFilter version="1.0">
           <filter root="/content/foo"/>
           <filter root="/content/dam/foo"/>
           <filter root="/content/usergenerated/content/foo"/>
        </workspaceFilter>
        
  6. Make sure to save all your changes. You can now synchronize that new content to your AEM instance.

  7. In the Servers panel, make sure that your connection is started, and if not start it.

  8. Click on the Clean and Publish icon.

Once done, you should have your package running on your instance, and on save, any change automatically gets synchronized to the instance.

If you wish to re-build a package out of your project, right-click on the PROJECT.ui.apps or PROJECT.ui.content and choose Run As -> Maven Install.

You now have a target folder that has been created with your package inside (called e.g. PROJECT.ui.apps-0.0.1-SNAPSHOT.zip).

Troubleshooting

Resolving Invalid Project Definition

To resolve invalid dependencies and project definition proceed as follows:

  1. Select all created projects.
  2. Right-click.
  3. In the context menu, select Maven -> Update Projects.
  4. Check Force Updates of Snapshot/Releases.
  5. Click OK.

Eclipse downloads the required dependencies. This may take a moment.

More information

The official Apache Sling IDE tooling for Eclipse website provides you with useful information:

The following official Eclipse documentation can help to set up your environment:

On this page