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 preconfigured settings.xml
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 on JIRA.
The following are the prerequisites 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.Install JDK. Java version 1.8.X is required for Atlassian Plugin SDK 6.1.0. Please verify the compatible Java version for your SDK version.
Make sure the
JAVA_HOME
is set properly and the commandjava -version
outputs the correct Java version details.
Once we have Java installed and the port ready, we can download the latest version of Atlassian plugin SDK from https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project.
Unzip the version into a directory of your choice or follow the instructions on the page, depending up on the operating system. Let's call this directory
SDK_HOME
going forward.Add the SDK's
bin
directory into the environmentPATH
variable. If you are using the installer, this step is automatically done.Create a new environment variable,
M2_HOME
, pointing to theapache-maven
directory in your SDK Home. SDK version 4.x+ handles this step automatically.Install the IDE of your choice. Atlassian recommends Eclipse, IntelliJ IDEA, or NetBeans, as they all support Maven.
Ready, set, go...
With the preceding steps executed properly, we have a development environment for JIRA plugins. You can verify the installation of the SDK by running the following command:
atlas-version
This command displays the version and runtime information of the installed SDK.
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.
If you face issues while downloading the dependencies using Maven, read on.
If you are behind a firewall, make sure you configure proxy in the Maven settings.xml
file. 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 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 the M2_HOME
directory to your local Maven and update the respective settings.xml
with the repository details in the default settings.xml
that ships with the Atlassian Plugin SDK.
Or you can simply add the following to the existing settings.xml
:
<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>
If you are using IntelliJ IDEA, it is an easy job because IDEA integrates Maven out of the box. Just load the project by selecting the pom.xml
! See https://developer.atlassian.com/docs/developer-tools/working-in-an-ide/configure-idea-to-use-the-sdk for 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/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/set-up-the-eclipse-ide-for-linux or https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/set-up-the-eclipse-ide-for-windows, depending on the OS.
For NetBeans, see https://developer.atlassian.com/docs/developer-tools/working-in-an-ide/configure-netbeans-to-use-the-sdk.
If you see Maven download errors such as 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 and/or firewall restrictions removed if none of the above works! Seriously, it makes a difference.