How to Develop AEM Projects Using Eclipse how-to-develop-aem-projects-using-eclipse

CAUTION
AEM 6.4 has reached the end of extended support and this documentation is no longer updated. For further details, see our technical support periods. Find the supported versions here.

This guide describes how to use Eclipse for developing AEM based projects.

NOTE
Adobe now provides the AEM Development Tools for Eclipse which helps you to develop AEM solutions with Eclipse.

Overview overview

To get started with AEM development on Eclipse, the following steps are required.

Each of them is expained in more detail in the remainder of this How-To.

  • Install Eclipse 4.3 (Kepler)
  • Set up your AEM project based on Maven
  • Prepare JSP support for Eclipse in the Maven POM
  • Import the Maven Project into Eclipse
NOTE
This guide is based on Eclipse 4.3 (Kepler) and AEM 5.6.1.

Install Eclipse install-eclipse

Download the “Eclipse IDE for Java EE Developers” from the Eclipse Downloads page.

Install Eclipse following the Installation Instructions.

Set up your AEM project based on Maven set-up-your-aem-project-based-on-maven

Next, set up your project using Maven as described in How-To Build AEM Projects using Apache Maven.

Prepare JSP Support for Eclipse prepare-jsp-support-for-eclipse

Eclipse can also provide support in working with JSP, e.g.

  • auto-completion of tag libraries
  • Eclipse-awareness of objects defined by <cq:defineObjects /> and <sling:defineObjects />

For that to work:

  1. Follow the instructions on How-To Work with JSPs in How-To Build AEM Projects using Apache Maven.

  2. Add the following to the <build /> section in your content module’s POM.

    Eclipse’s Maven support plugin, m2e, does not provide support for the maven-jspc-plugin, and this configuration tells m2e to ignore the plugin and the related task of cleaning up the temporary compilation results.

    This is not a problem: as noted in How-To Work with JSPs, the maven-jspc-plugin in this setup is only used to validate that JSPs compile as part of the build process. Eclipse already reports any problems in JSPs and does not rely on this Maven plugin to be able to do so.

    myproject/content/pom.xml

    code language-xml
    <build>
      <!-- ... -->
      <pluginManagement>
        <plugins>
          <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
          <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
              <lifecycleMappingMetadata>
                <pluginExecutions>
                  <pluginExecution>
                    <pluginExecutionFilter>
                      <groupId>org.apache.sling</groupId>
                      <artifactId>maven-jspc-plugin</artifactId>
                      <versionRange>[2.0.6,)</versionRange>
                      <goals>
                        <goal>jspc</goal>
                      </goals>
                    </pluginExecutionFilter>
                    <action>
                      <ignore/>
                    </action>
                  </pluginExecution>
                  <pluginExecution>
                    <pluginExecutionFilter>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-clean-plugin</artifactId>
                      <versionRange>[2.4.1,)</versionRange>
                      <goals>
                        <goal>clean</goal>
                      </goals>
                    </pluginExecutionFilter>
                    <action>
                      <ignore/>
                    </action>
                  </pluginExecution>
                </pluginExecutions>
              </lifecycleMappingMetadata>
            </configuration>
          </plugin>
        </plugins>
      </pluginManagement>
    </build>
    

Import the Maven Project into Eclipse import-the-maven-project-into-eclipse

  1. In Eclipse, choose File > Import…

  2. In the Import Dialog, choose Maven > Existing Maven Projects, then click “Next”.

    chlimage_1-41

  3. Enter the path to your project’s top-level folder, then click “Select All” and “Finish”.

    chlimage_1-42

  4. You are now all set for using Eclipse to develop your AEM project, including JSP autocompletion.

    chlimage_1-43

    note note
    NOTE
    If you include /libs/foundation/global.jsp or other JSPs in /libs, you will need to copy that to your project so Eclipse can resolve the inclusion. At the same time, you need to make sure that it is not bundled into your content package by Maven. How to achieve this is described in How to Build AEM Projects using Apache Maven.
recommendation-more-help
2315f3f5-cb4a-4530-9999-30c8319c520e