M2Eclipse-not-supported

Atlassian plugins with eclipse & maven

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.

1. Get ready for 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.

To finish eclipse configuration we set the maven’s reposotory path as an environment variable. We can do that invoking the following command in a terminal:

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:

By executing this command a new variable path is created in eclipse with the name M2_REPO that refers to the repository folder.

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:

atlas-create-jira-plugin

During the command execution you’ll be prompted for JIRA’s version, GroupId, ArtifactId, plugin version, etc. The expected output is something like:

This will create a Maven project and the pom.xml file. Now we create an eclipse project skeleton by running the following command inside the plugin’s folder:

atlas-mvn eclipse:eclipse

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.

Upon successfull run a  test-plugin-1.0-SNAPSHOT.jar file will be created in the target subdirectory. Now it is time to deploy.

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..

Regards.

Author: Eduardo Mayor

Eduardo Mayor is a software engineer with 20+ years of experience. He is also the founder of Novagenia Information Technologies, a company focused on introducing agile methods and tools to companies worldwide.

Visit us in: http://www.novagenia.com
Share this...

12 thoughts on “Atlassian plugins with eclipse & maven

  1. Muy buen articulo! Para aquellos que no quieran empezar desde cero tienen la posibilidad de aprovechar alguno de los plugins que proporciona Atlassian u otros como base, un buen ejemplo es el Jira Suite Utilities que contiene custom fields, validaciones, condiciones, post-funciones y más!

    https://plugins.atlassian.com/plugin/details/5048

    Desde aquí se puede descargar los fuentes:
    https://studio.plugins.atlassian.com/svn/JSUTIL/jars/jira-suite-utilities-1.1.2-sources.jar

    Saludos!

    1. Joann,
      We have added a simple facebook like button on the sidebar that is accessible at all times on our blog. Besides, there are social counters for every post.

      Thanks for taking the time to comment on our blog. We appreciate your help.

      Best,
      Eduardo

  2. Despues de ejecutar el comando “atlas-create-confluence-plugin”, me aparece un BUILD ERROR, notificandome exactamente lo siguiente:

    Error building POM (may not be this projects POM)

    Parece ser que o no encuentra el POM o el com.atalassian.maven.plugins:maven-confluence-plugin en el repositorio…alguna idea?

    Intento seguir tu guia para intentar modificar el plugin de WebDAV en Confluence y a ver si de esta forma puedo meterle mano. Si existe alguna otra y la conoces, te agradeceria que me comentases por encima la forma..

    Muchas gracias!

  3. Buenas,
    Muy bueno el artículo. En mi humilde opinión, yo pienso que es mucho mejor utilizar la instancia de Jira que te crea la propia sdk de jira cuando ejecutas el comando atlas-debug, ya que además de poder elegir la versión de Jira sobre la que deseas que corra el plugin (en el pom.xml) puedes debuguear (será que soy anti-trazas xD), incluso a veces (no se por qué) debugueando, si cambias alguna chorradilla en el código y guardas, te pilla los cambios en caliente (incluso debugueando remotamente contra tu servidor).
    Además, en lugar de tener que compilar e instalar manualmente el plugin desde la UI de Jira, se puede utilizar el comando atlas-cli (pi) para compilar, empaquetar e instalar automáticamente el plugin por consola, o usar FastDev.
    En fin, que hay otros muchos comandos útiles que pueden facilitarnos las cosas si utilizamos este método.

    Un saludo

    1. Leonardo,
      Muchas gracias por tu comentario. Efectivamente, la forma ideal para depurar es mediante la instancia de depuración y a través de FastDev. Yo tampoco soy amigo de utilizar trazas si se pueden evitar y con los comandos del SDK de Atlassian es trivial realizar y probar cambios en caliente sobre la instancia de JIRA. Para mí, el nirvana consiste en trabajar sobre eclipse (con ciclos de codificación, tests de unidad y generación con maven del jar) y recurriendo a Fastdev para probar los cambios sobre la instancia de jira de depuración.

      Tras la salida de JIRA 6 intentaré trabajar en una secuela de este post donde se introduzcan todas estas herramientas y algunos otros trucos para incrementar la productividad. De hecho tengo pendiente realizar algunos cambios para reflejar incompatibilidades en las últimas versiones del SDK así como links que han cambiado.

      Te agradezco de nuevo tus sugerencias y te animo a seguir aportando ideas a la comunidad.

      Saludos.
      Eduardo

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>