Where to start developing a plugin for JIRA?

    Using a powerful, customizable bug / task-tracker JIRA (or Confluence), over time it comes to the understanding that in some cases there is a lack of the necessary functionality that cannot be obtained from the standard plugins presented on the site. Due to this, having to go to a new level: own development. When this time comes, questions arise: where to start? There are a lot of dependencies between libraries in JIRA and Confluence, how to link them together to create the right one? Where to do it all?
    This article will not explain how to make a plugin, because each approach requires different approaches. I’ll only tell you how to prepare a platform for development.

    For development, you will need knowledge of Java, velocity and Weber html, css, js. Some experience in the IDE for Java (in this case I use Eclipse), friendship with tomcat, mysql and the installed JIRA tracker, in which the developed plug-in will be tested.
    All work is carried out in the OS Gentoo 2008. Already installed:
    • Tomcat-5.5.27-r3 ( emerge -av "=" www-servers / tomcat-5.5.27-r3 )
    • MySQL-5.0.70-r1 ( emerge -av dev-db / mysql )
    • Atlassian JIRA 3.13.2- # 335 Enterprise Edition (taken from the site and installed as described)
    • Eclipse 3.4.2

    note: If you are installing JIRA with a MySQL database, do not forget to install mysql-connector-java to configure operation with the MySQL database server, and in Linux you may need the naming-factory-dbcp.jar library, which you need to extract from the archive with Sandalone-JIRA for Windows and put it in /usr/share/tomcat-5.5/common/lib/)
    note 2: Check for installed JDK no lower than 1.5

    2. Installing Maven2


    The installation for Gentoo comes from the ports: emerge -av maven-bin , while version 2.0.9 is currently installed, which suits the requirements for developing the plugin. For Widnows, you have to put your hands on the site: http://maven.apache.org/download.html .
    In order for Maven to find dependencies when building the plugin, you will need to indicate where everything is stored. In the $ HOME / .m2 directory, put the settings.xml file . An example of this file can be said on the page: http://confluence.atlassian.com/display/DEVNET/Example+settings.xml .

    3. Creating a plugin skeleton


    So we got to the beginning, with which the development of the plug-in for JIRA begins (yes, in general, and for all applications from atlassian): creating an architecture skeleton. In general, everything is trivial here, you need to run the mvn command with a set of keys. All the required commands for creating the skeleton of the plugin architecture for applications can be found on the page: http://confluence.atlassian.com/display/DEVNET/Atlassian+Plugin+Archetypes . In our case, for JIRA, you need to run the following set: Next, so that the IDE can understand that it is her project, in the created folder, run the command: mvn eclipse: eclipse . Once you need to specify for Ecplise where the libraries from Maven are located, to do this, run the following: mvn -Declipse.workspace =
    mvn archetype:create \
    -DarchetypeGroupId=com.atlassian.maven.archetypes \
    -DarchetypeArtifactId=jira-plugin-archetype \
    -DarchetypeVersion=15 \
    -DremoteRepositories=https://maven.atlassian.com/repository/public/ \
    -DgroupId=$MY_PACKAGE -DartifactId=$MY_PLUGIN




    Actually, in order to simplify the procedure for creating a plug-in skeleton in the workspace folder from Eclipse, I created the atchetype.sh file in which I placed the necessary commands. Next, I entered the variables $ MY_PACKAGE and $ MY_PLUGIN into which you need to enter the package name and the name of the created plug-in and added the project creation commands for the IDE: Now just run ./archetype.sh <package name> <plug-in name> and the whole structure will be created. If it is launched for the first time, it will download several dozen small files - jar-libraries, which will be required in the standard dependencies of the developed plug-in for JIRA or Confluence.
    #!/bin/sh
    if [ -z "$1" ]; then
    echo "archetype "
    else
    MY_PACKAGE=$1
    fi
    if [ -z "$2" ]; then
    echo "archetype "
    else
    MY_PLUGIN=$2
    fi
    mvn archetype:create \
    -DarchetypeGroupId=com.atlassian.maven.archetypes \
    -DarchetypeArtifactId=jira-plugin-archetype \
    -DarchetypeVersion=15 \
    -DremoteRepositories=https://maven.atlassian.com/repository/public/ \
    -DgroupId=${MY_PACKAGE} -DartifactId=${MY_PLUGIN}
    cd ./${MY_PLUGIN}
    mvn eclipse:eclipse



    4. Development begins


    Then we simply import the finished project into Eclipse. And you can start productively programming to create a new plug-in for JIRA or Confluence in the future. :)

    Adding libraries to Maven repository


    In some cases, you will need to add the library to the Maven repository, for example, javax.mail does not automatically download, because license agreement required. In the case of javax.mail-1.3.2: go to the folder: $ HOME / .m2 / repository / javax / mail / mail / 1.3.2 in the mail-1.3.2.pom file we find the link where to download the required library from and download archive with her. The archive has the documentation and the mail.jar we need. Then we add it to the repository with the command: mvn install: install-file -DgroupId = javax.mail -DartifactId = mail -Dversion = 1.3.2 -Dpackaging = jar -Dfile = <path to the library> mail.jar . For other libraries, you will need to change the data in the -DgroupId , -DartifactId , -Dversion keys .

    Plugin assembly


    After the plugin has been written, before installation, you will need to compile it: mvn source: jar install -Dmaven.test.skip = true, run in the project folder and get the jar in the target folder. We copy the resulting jar to WEB_INF / lib and restart tomcat. If everything is in order, then in the Administration → System → Plugins section, you can find the created plugin. In case of possible errors: look at the logs and correct.

    Also popular now: