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 plugin development easier, Atlassian provides the Atlassian Plugin Software Development Kit (SDK). It comes along with Maven and a pre-configured settings.xml
to make things easier.
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
The following are the pre-requisites for running the Atlassian plugin SDK:
The default port for the SDK: 2990 should be available. This is important because different ports are reserved for different Atlassian products.
JDK Java version 1.5 - 6 must be installed.
Make sure
JAVA_HOME
is set properly and the commandjava –version
outputs the correct Java version details.And of course, JIRA 4.x+ should be installed in your development environment.
Note
Make sure you use a context path for your JIRA because there are known issues with the SDK not working when the context path is empty. See https://studio.atlassian.com/browse/AMPS-122 for more details.
How to do it...
Once we have Java installed and the port ready, we can download the latest version of Atlassian Plugin SDK from https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/amps/atlassian-plugin-sdk/.
Unzip the version into a directory of your choice. Let's call this directory
SDK_HOME
going forward.Add the SDK's bin directory into the environment
PATH
variable.Create a new environment variable
M2_HOME
pointing to the Apache-Maven directory in your SDK Home.A lot of commonly used dependencies are already available in the repository folder embedded in the SDK. To use this, edit the
settings.xml
underM2_HOME/conf/
and modify thelocalRepository
attribute to point to the embedded repository folder. By default, it will use theUSER_HOME/.m2/repository
.Install the IDE of your choice. Atlassian recommends Eclipse, IntelliJ IDEA, or NetBeans, as they all support Maven.
Ready, Set, Go…
How it works...
With these steps executed properly, we have a development environment for JIRA plugins.
The next step is to create a Skeleton plugin, import it into your IDE, and start writing some code! Creating the Skeleton plugin, deploying it, and so on, is explained in detail in the following recipes.
There's more...
Even though the aforementioned steps will work in most cases, we will come across scenarios where the setting up of the development environment is not that straightforward. For example, there are extra settings needed for Maven if the machine is behind a firewall. You might even have a local Maven version already installed. In this section, we will see some useful tips on similar cases.
Proxy settings for Maven
If you are behind a firewall, make sure you configure the proxy in the Maven settings.xml
file. The 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>
Find out more about that and other aspects of Maven at 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 M2_HOME
to your local Maven and update the respective settings.xml
with the repository details in the default settings.xml
that ships with Atlassian plugin SDK.
Configuring IDEs to use SDK
If you are using IntelliJ IDEA, it is an easy job because IDEA integrated Maven out-of-the-box. Just load the project by selecting the pom.xml
!
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 http://confluence.atlassian.com/display/DEVNET/Configuring+Eclipse+to+use+the+SDK.
Troubleshooting
If you see Maven download errors like Could not resolve artifact, make sure you verify the following:
Entry in Maven
settings.xml
is correct. That is, it points to the correct repositoriesProxy configuration is done if required
Antivirus in the local machine is disabled if none of the above works! Seriously, it makes a difference.
See also
Creating a skeleton plugin