Developing your first plugin - Importing your plugin into IntelliJ

This guide shows how to import a new plugin that was created using a Maven archetype into IntelliJ.

Prerequisites

Before using this guide ensure that you have installed Java, Apache Maven and IntelliJ on your computer as outlined in part 1: setting you your development environment, and have generated a new plugin using a Maven archetype.

Import a new plugin into IntelliJ

  1. Open IntelliJ and click Open or Import. If you have previously opened a project you may need to select File  New  Project from Existing Sources…​ from the menu.

  2. Navigate to the folder containing the new plugin that you created in the previous step (my-plugins-directory/title-prefix-plugin) and select the pom.xml file.

  3. If you are prompted select that you wish to import the project as a maven project.

  4. If you are prompted to select an SDK choose JDK 11. This is the Java version installed in a previous step.

Importing documentation from Maven

The Funnelback interfaces that you will be developing against include documentation. A key advantage of using an IDE such as IntelliJ is that this documentation is available from within the IDE.

Some additional configuration steps are required in order for the documentation to be available from within IntelliJ:

  1. Open the preferences window by selecting File  Settings/Preferences from the menu.

  2. Search for maven in the menu and click on the Importing item.

  3. Tick the boxes for Automatically download: Sources, Documentation and Annotations.

    download_sources
  4. Click Apply, then click OK.

Exploring the imported project

The imported project is now ready to use. Expand the project structure by clicking on the Project tab then expanding out the project tree.

There are five main files of interest:

project_layout
  1. PluginUtils: This class defines helpful methods that are specific to writing your plugin.

  2. TitlePrefixPluginSearchLifeCyclePlugin: This contains the code that implements the functionality of the plugin. In this example there is only a single TitlePrefixPluginSearchLifeCyclePlugin file included in this folder as we only generated searchLifeCycle when generating the plugin. A file is created here for each interface template that was selected when the plugin was generated from the Maven archetype.

  3. TitlePrefixPluginSearchLifeCyclePluginTest: This contains code that implements unit tests to make sure the plugin is working correctly. A test file will be generated for each interface that was selected when generating the plugin in the same way as for the main plugin code above. Unit testing of plugins are covered in more detail in the testing section of the tutorial.

  4. pom.xml: This file defines a number of parameters that maven uses to package the project. Other libraries required by the plugin will automatically be added to this by IntelliJ.

  5. README.md: This file includes documentation for the plugin and must be included for every plugin.

Next steps

The next tutorial covers the implementation of the plugin functionality.

© 2015- Squiz Pty Ltd