-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
JIRA Development Cookbook
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.
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 command java –version outputs the correct Java version details.
And of course, JIRA 4.x+ should be installed in your development environment.
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.
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 under M2_HOME/conf/ and modify the localRepository attribute to point to the embedded repository folder. By default, it will use the USER_HOME/.m2/repository.
Install the IDE of your choice. Atlassian recommends Eclipse, IntelliJ IDEA, or NetBeans, as they all support Maven.
Ready, Set, Go…
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.
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.
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.
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.
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.
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 repositories
Proxy configuration is done if required
Antivirus in the local machine is disabled if none of the above works! Seriously, it makes a difference.
Creating a skeleton plugin
Change the font size
Change margin width
Change background colour