Setting up the development environment
Now that we know what a plugin is, let's aim at writing one! The first step in writing a JIRA plugin is to set up your environment—if you haven't done that already. In this recipe, we will see how to set up a local environment.
To make our plugin development easier, Atlassian provides the Atlassian plugin software development kit (SDK). It comes along with Maven and a preconfigured settings.xml
file to make things easier.
The Atlassian plugin SDK can be used to develop plugins for other Atlassian products, including Confluence, Crowd, and so on, but we are concentrating only on JIRA.
Getting ready
Following are the prerequisites for running the Atlassian plugin SDK:
The default port 2990 for the SDK should be available. This is important because different ports are reserved for different Atlassian products.
JDK should be installed and Java version 1.6.x is required.
Note
The SDK is not yet compatible with Java 1.7.
Make sure the
JAVA_HOME
environment variable is set properly and thejava -version
command outputs the correct Java version details.
How to do it…
Following are the steps to set up our development environment:
Once we have installed Java and the port 2990 is ready, we can download the latest version of Atlassian plugin SDK from https://developer.atlassian.com/display/DOCS/Getting+Started.
Install the SDK by following the instructions provided on the Atlassian Developer Documentation page, depending upon the operating system. Let's call this directory
SDK_HOME
.Add the SDK's
bin
directory into the environmentPath
variable.Create a new environment variable,
M2_HOME
, pointing to theapache-maven
directory in your/SDK_HOME/atlassian-plugin-sdk
directory.Note
SDK version 4.x and above doesn't need this step.
A lot of commonly used dependencies are already available in the
repository
folder embedded in the SDK. To use this, edit thesettings.xml
file underM2_HOME/conf/
by modifying thelocalRepository
attribute to point to the embeddedrepository
folder. By default, it will use theUSER_HOME/.m2/repository
directory.Install the IDE of your choice. Atlassian recommends Eclipse, IntelliJ IDEA, or NetBeans, as they all support Maven.
With the preceding steps executed properly, we have a development environment for JIRA plugins. The next step is to create a skeleton plugin, import it in to your IDE, and start writing some code! Creating the skeleton plugin, deploying it, and so on, is explained in detail in the forthcoming recipes of this chapter. So, ready, set, go…
There's more…
If you are facing issues while downloading the dependencies using Maven, just read on.
Proxy settings for Maven
If you are executing behind a firewall, make sure you have configured proxy settings in Maven's settings.xml
file. A proxy can be configured as follows:
<settings> . <proxies> <proxy> <active>true</active> <protocol>http</protocol> <host>proxy.demo.com</host> <port>8080</port> <username>demouser</username> <password>demopassword</password> <nonProxyHosts>localhost|*.demosite.com</nonProxyHosts> </proxy> </proxies> . </settings>
Note
To find out more about proxy settings for Maven and other aspects of it, go to http://maven.apache.org/index.html.
Using local Maven
If you are a developer, in many cases you will have Maven already installed in your local machine. In that case, point the M2_HOME
environment variable to your local Maven, and update the respective settings.xml
file with the repository details in the default settings.xml
file that ships with the Atlassian plugin SDK. Or, you can simply add the following lines to the existing settings.xml
file:
<pluginRepository> <id>atlassian-plugin-sdk</id> <url>file://${env.ATLAS_HOME}/repository</url> <releases> <enabled>true</enabled> <checksumPolicy>warn</checksumPolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository>
Configuring IDEs to use the SDK
If you are using IntelliJ IDEA, configuring it to use the SDK is an easy job because IDEA integrates Maven out of the box. Just load the project by selecting the pom.xml
file! See https://developer.atlassian.com/display/DOCS/Configure+IDEA+to+use+the+SDK for more details.
If you are using Eclipse, make sure you have m2eclipse installed. This is because Eclipse integrates Maven through the Sonatype m2eclipse plugin. You can find more details on configuring this at https://developer.atlassian.com/display/DOCS/Set+Up+the+Eclipse+IDE+for+Linux for Linux, or https://developer.atlassian.com/display/DOCS/Set+Up+the+Eclipse+IDE+for+Windows for Windows.
If you are using Netbeans, check out https://developer.atlassian.com/display/DOCS/Configure+NetBeans+to+use+the+SDK on how to configure it to use the SDK.
Troubleshooting
If you see Maven download errors such as "Could not resolve artifact", make sure you verify the following:
Entry in Maven's
settings.xml
file is correct. That is, it points to the correct repositories.Proxy configuration is done if required.
Antivirus in the local machine is disabled and/or firewall restrictions removed if none of the above works! Seriously, it makes a difference.
See also
The Creating a skeleton plugin recipe