In this article we show how to create a plugin for JIRA, Confluence or Bamboo using eclipse and maven plugin overcoming current limitations on Atlassian SDK.
Atlassian provides an SDK for plugins (and other artifacts as well ) creation that simplifies the setup of a complex environment. Platform requirements: Java Development Kit (JDK) version 6 you can download here.
The Atlassian SDK comes with a Maven instalation with extra tools that helps jumpstarting a plugin. Download the latest SDK from this location and uncompress on a local path without spaces. Finally add the Maven’s bin folder to your path.
Then we will install the IDE, making sure we user eclipse Helios for Java development. Important! The latest eclipse version (when this entry was written) is Indigo which is incompatible with Atlassian SDK Atlassian and you won’t be able to use eclipse pluginj for Maven: M2Eclipse. Eclipse Helios can be downloaded from this link. Again, avoid spaces in eclipse installation path.
2. Configure eclipse
Eclipse plugin for Maven won’t run on a JRE so you need to make sure it starts with a Java Development Kit (JDK). In order to avoid trouble you can modify eclipse configuraion file eclipse.ini and specify the path to the installed JDK:
-vm C:/Program Files/Java/jdk1.6.0_29/bin
Eclipse Helios does not came bundeled with M2Eclipse plugin so we will add it manually. This way we can resort to a plugin version compatible with Atlassian SDK: http://m2eclipse.sonatype.org/installing-m2eclipse.html. Add the Update repository and select Maven Integration for Eclipse for installation.
Sonatype’s plugin version includes an embedded Maven installation that must be replaced for the one bundled in the Atlassian SDK. In the plugin configuration Window->Preferences->Maven->Installations we create a new entry for the Maven installation.
atlas-mvn eclipse:add-maven-repo "-Declipse.workspace="
On windows, it is important to use double quotes in order for the workspace pth to be resolved correctly. If the command executed successfully you should see some like:
3. Create your first plugin
We are now ready to start writing plugins. There are several alternatives depending on the affected product and the kind of artifact you are building. We will use the SDK tools for the sake of simplicity.
Using the command-line on a terminal, Execute the following command in the workspace path:
During the command execution you’ll be prompted for JIRA’s version, GroupId, ArtifactId, plugin version, etc. The expected output is something like:
This command will update current dependencies depending on the product and version. Now our plugin is ready to be imported into eclipse either as an eclipse or as a Maven project.
E voilà! The project is ready to generate our first plugin.
4. Build, depoly and test
This project will build automatically. In order to create a plugin package we will resort to the maven tools. Select the project in eclipse and click on Run As->Maven package.
Install JIRA if you haven’t already. You can download the latest version installer from here. You can acquire a comercial license for just 10$ …
Log in JIRA with administrator privileges click on Administration->Plugins. On the Install tab, click on Upload plugin and select the jar file we just created from eclipse.
Once the process finishes, the plugin is loaded and ready to play. Improve it, extend funcionality, change the plugin version and generate a new jar file as explained. You can deploy newer versions of the plugin without the hassle or restarting JIRA.
For simple debugging add your plugin’s groupid to the log4j.properties file and restart. From the administration page you can further customize the logging levels for every entry in the file.
log4j.logger.com.novagenia = DEBUG, filelog log4j.additivity.com.novagenia = false
6. Explore new possibilities
Explore the SDK to get a glimpse of all you can do by creating plugins. There is a site devoted to developers regarding Atlassian products: http://developer.atlassian.com.
When your plugin is production-ready, register it in the Atlassian plugin repository and share with the community: http://plugins.atlassian.com.
I hope this was helpful. Tell us what you think..