Prepare JSP Support for IntelliJ IDEA

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

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

For that to work, follow the instructions on How-To Work with JSPs in How-To Build AEM Projects using Apache Maven.

Import the Maven Project

  1. Open the Import dialog in IntelliJ IDEA by

    • selecting Import Project on the welcome screen if you have no project open yet
    • selecting File -> Import Project from the main menu
  2. In the Import dialog, select the POM file of your project.

    chlimage_1-45

  3. Continue with the default settings as shown in the dialog below.

    chlimage_1-46

  4. Continue through the following dialogs by clicking Next and Finish.

  5. You are now set up for AEM Development using IntelliJ IDEA

    chlimage_1-47

Debugging JSPs with IntelliJ IDEA

The following steps are necessary for debugging JSPs with IntelliJ IDEA

  • Set up a Web Facet in the Project
  • Install the JSR45 support plugin
  • Configure a Debug Profile
  • Configure AEM for Debug Mode

Set up a Web Facet in the Project

IntelliJ IDEA needs to understand where to find the JSPs for debugging. As IDEA cannot interpret the content-package-maven-plugin settings, this needs to be configured manually.

  1. Go to File -> Project Structure
  2. Select the Content module
  3. Click + above the list of modules and select Web
  4. As the Web Resource Directory, select the content/src/main/content/jcr_root subdirectory of your project as shown in the screen shot below.

chlimage_1-48

Install the JSR45 support plugin

  1. Go to the Plugins pane in the IntelliJ IDEA settings
  2. Navigate to the JSR45 Integration Plugin and select the check box next to it
  3. Click Apply
  4. Restart IntelliJ IDEA when requested to

chlimage_1-49

Configure a Debug Profile

  1. Go to Run -> Edit Configurations
  2. Hit the + and select JSR45 Remote
  3. In the configuration dialog, select Configure next to Application Server and configure a Generic server
  4. Set the start page to an appropriate URL if you want to open a browser when you start debugging
  5. Remove all Before launch tasks if you use vlt autosync, or configure appropriate Maven tasks if you don’t
  6. On the Startup/Connection pane, adjust the port if required
  7. Copy the command line arguments that IntelliJ IDEA proposes

chlimage_1-50 chlimage_1-51