LDSTechForumProjects

Getting Started with IntelliJ IDEA

IntelliJ IDEA is a commercial alternative to the LDSTech IDE. IntelliJ can be used for developing applications use the LDS Java Stack. This tutorial assume that you already have IntelliJ installed and running.

Opening a Java Stack Application

  • Go to File | Open Project... from the menu bar
  • When the Open Project dialog comes up, go the project's root directory, select the pom.xml file, and select OK. IntelliJ will then import your project and all of its modules.

As the project gets imported, IntelliJ may offer to add various .iml files to Subversion for you. Select No when these dialog boxes appear. All the needed project configuration is held in the pom.xml files

Configuring Maven in IntelliJ

IntelliJ can import Maven pom.xml files without any configuration changes. However, IntelliJ cannot execute Maven tasks without referring to a Maven installation. Older versions of the Stack may require Maven 2.

  • Go to http://maven.apache.org/download.html
    • For building projects using Stack 2.1.x, download the latest version of Maven 2.0.x
    • For building projects using Stack 2.2+ and 3.x, download the latest version of Maven 3.0.x
  • Unzip the archive to a location on your hard drive
    • Set the environment variable M2_HOME to the folder where you installed Maven. By default, IntelliJ refers to M2_HOME to determine what Maven installation to use to run Maven goals.
    • (Recommended) Add %M2_HOME%\bin to your PATH environment variable.

You may work on projects that require different versions of Maven. To specify a version of Maven for a particular project, do the following:

  • Open the project, then go to File | Settings...
  • After the Settings dialog opens, select Maven in the Project Settings list
  • Under the Maven settings, go to Maven home directory and select the Override check box to the right of the input box. In the input box enter the location of the Maven installation you would like to use on the project.

If you have errors like unable to get dependency information unable to read the metadata file for artifact

  • open settings -> maven -> importing
  • check the box Use Maven3 to import project

Deploying and Running Applications

Creating a Configured Tomcat Instance

Java Stack applications have a deploy module that contains deployment properties for each environment the application will be deployed in (dev, test, staging, production, etc.). These properties hold values specific to each of these environments such as database connection information, logging settings, and Tomcat settings.

The LDSTech IDE uses these properties automatically when running Tomcat. When using IntelliJ, you must create a custom Tomcat instance that will use these properties. Fortunately, the Stack provides a relatively simple way of doing this.

Perform a Maven Install on the Project

NOTE: This must be done before creating the custom Tomcat instance so that the deployable war is available for configuring the Tomcat instance.

  1. Select the Maven Projects button on the right side of the IDE window
  2. Select the root module of the project
  3. Expand the selection to Lifecycle | install
  4. Click on the Run Maven Build button Intellijrun.png at the top of Maven Projects window

Config Tomcat Deployment for the Project

  1. Select the Maven Projects button on the right side of the IDE window
  2. Select the deploy module of the project
  3. Expand the selection to Plugins | stack-tomcat | stack-tomcat:config
  4. Right-click on stack-tomcat:config and select the Create "...-deploy ... option. A Create Run/Debug Configuration dialog will appear.
  5. Rename the configuration to something more readable, like "Configure Tomcat"
  6. Select the Runner tab, un-check the "Use Project Settings" box, then click the Add button Intellijplus.png next to the Properties list
  7. Add a property called "tomcatTargetDir" that points to where you would like the Tomcat installation to be placed. By default, the Tomcat configuration plugin will place the custom Tomcat instance in PROJECT_ROOT/deploy/target. Since this directory will be deleted when executing a Maven clean goal, it is recommended that you specify a directory outside of your project to store the custom Tomcat instance.
  8. Click OK to add the new Maven property
  9. In the "Before Launch" section click the plus button (you may need to scroll or resize the window).
  10. Choose "Run Maven Goal" at the bottom of the list.
  11. Expand the root of your project (you can expand the deploy module instead of the root if you prefer).
  12. Expand Lifecycle, choose "package" and click Ok. (This makes sure the artifact is current before configuring tomcat).
  13. Click OK to save the new run configuration.

To run the Tomcat configuration, select the newly-created run configuration from the list of configurations on the main tool bar Intellijrunconfiguretomcat.pngand then click the Run toolbar button Intellijrun.png next to the list.

Note: Since the configured Tomcat instance is created using configuration in your deploy project you will need to run this configuration whenever you make any changes to your deploy project.

More information on the Maven plugin that creates the Tomcat instance can be found in the Stack Tomcat Deploy reference documentation.

Using the Configured Tomcat Instance

To use the newly created Tomcat instance,

  1. Select Run | Edit Configurations from the drop down menu
  2. Select the Add New Configuration button Intellijplus.png and then select Tomcat server | Local. This will create a new Tomcat server run/debug configuration.
  3. Give the new configuration a name
  4. Next to the Application Server drop down, select the Configure button.
  5. If the Application Servers dialog box appears click on the Add button Intellijplus.png to bring up the Tomcat Server dialog box. If the Tomcat Server dialogue appears proceed to the next step.
  6. In the Tomcat home: input box enter the directory to the Tomcat instance you created in the Config Tomcat Deployment for the Project section above.
  7. Select OK. This will create a new Tomcat run configuration.
  8. If you are returned to the Application Servers dialog box click OK to close it. Otherwise continue.
  9. Switch to the Deployment tab (for IntelliJ 12+, otherwise skip this step)
  10. Click Add button Intellijplus.png next to the Deploy at Server Startup section
  11. Select Artifact...
  12. There will be multiple artifacts listed. Select the artifact that ends in ...-web:war exploded.
  13. In Application context field, enter the context path for your project. It is recommended that you specify the same context path that the Maven project has. In most cases, the context path can be found in the root POM file of your project as a contextRoot property.
  14. Click OK to close the Select Artifacts to Deploy dialog (IntelliJ 11 and earlier)
  15. Click OK

To run the Tomcat configuration, select the newly-created run configuration from the list of configurations on the main tool bar Intellijruntomcat.png, then click the Run button Intellijrun.png. This will launch Tomcat and open a browser to your application.

JVM Settings for Tomcat Instance

Intellijeditconfigjvm.png

While projects using the LDS Tech IDE leverage the jvmarg.properties file in a Stack project configure settings for the custom Tomcat instances, IntelliJ does not. To explicitly add the JVM arguments to your custom Tomcat instance, do the following:

  1. Select Run | Edit Configurations from the drop down menu.
  2. Select your Stack application run configuration from the list of configurations in the Run/Debug Configurations dialog. The configuration should be listed under the Tomcat Server section of configurations.
  3. In the VM options entry box, enter the JVM arguments that you would like to apply to the configuration
  4. Click OK

To determine what JVM arguments that you should use, refer to the jvmargs.properties file contained in your project. The jvmargs.properties file section of the Stack Tomcat Deployable reference documentation can also help to determine which JVM arguments to specify.

Running the WAM Emulator

(For Stack 3.x projects)

  1. Select the Maven Projects button on the right side of the IDE window
  2. Select the module in your project where the stack-wam plugin exists:
    • For Stack 3.0.x and 3.1.x projects, this will be the wam module.
    • For Stack 3.2.x and greater projects, this will be the ALM module.
  3. Expand the selection to Plugins | stack-wam | stack-wam:run
  4. Right-click on stack-wam:run and select the Create ... option. A Create Run/Debug Configuration dialog will appear.
  5. Rename the configuration to something more readable, like "Start Wamulator"
  6. Click OK to save the new run configuration.

To run the WAM emulator, select the newly-created run configuration from the list of configurations on the main tool bar Intellijrunstartwamulator.png, then click the Run button Intellijrun.png.

This page was last modified on 4 March 2014, at 11:18.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.