📜 ⬆️ ⬇️

How to start developing a plugin for JIRA?

Using a powerful, customizable JIRA (or Confluence) bug / task tracker, with time comes an understanding that in some cases the necessary functionality is missing, which cannot be obtained from standard plug-ins and presented on the website. Because with this, it comes to a new level: own development. When this time comes, the questions arise: where to start? In JIRA and Confluence, a bunch of dependencies between libraries, how to tie them together to create the right one? Where does all this do?
This article will not tell you how to make a plugin, because for each option requires different approaches. I'll tell you just how to prepare a platform for development.

The development will require knowledge of Java, velocity and Weber html, css, js. Some experience in IDE for Java (in this case, I use Eclipse), friendship with tomcat, mysql and the installed JIRA tracker, in which the plugin being developed will be tested.
All work is carried out in the OS Gentoo 2008. Already installed:

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

2. Install Maven2


The installation for Gentoo proceeds from the ports: emerge -av maven-bin , while at the moment version 2.0.9 is being installed, which fits the requirements for plug-in development. 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 a plugin, you need to specify 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 plug-in skeleton


This is where the development of the plug-in for JIRA begins (and in general, and for all applications from atlassian): creating the skeleton of the architecture. In general, everything is banal, you need to run the mvn command with a set of keys. All required commands for creating the skeleton of the plug-in architecture for applications can be found on the page: http://confluence.atlassian.com/display/DEVNET/Atlassian+Plugin+Archetypes . In our case, JIRA will need to run the following set:
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

Further, in order for the IDE to understand that this is its project, run the command in the created folder: mvn eclipse: eclipse .
Once you need to specify for Ecplise where are the libraries from Maven, for this run the following:
mvn -Declipse.workspace = <path-to-eclipse-workspace>
Actually, in order to simplify the procedure for creating the skeleton of the plugin in the workspace folder from Eclipse, I created the atchetype.sh file in which I placed the necessary commands. Then I entered the variables $ MY_PACKAGE and $ MY_PLUGIN into which you need to enter the package name and the name of the plugin being created, and added the project creation commands for the IDE:
#!/bin/sh
if [ -z "$1" ]; then
echo "archetype <package_name> <plugin_name>"
else
MY_PACKAGE=$1
fi
if [ -z "$2" ]; then
echo "archetype <package_name> <plugin_name>"
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

Now just run ./archetype.sh <package name> <plugin name> and the whole structure will be created. If it is launched for the first time, then several dozens of small files will be downloaded - jar-libraries, which will be required in the standard dependencies of the plugin being developed for JIRA or Confluence.
')

4. Development begins


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

Adding Libraries to Maven Storage


In some cases, you will need to add a library to the Maven repository, for example, javax.mail is not automatically downloaded, because license approval 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 file mail-1.3.2.pom we find the link from where to download the required library and download archive with her. In the archive documentation and 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 library> mail.jar . For other libraries, you need to change the data in the keys -DgroupId , -DartifactId , -Dversion .

Plugin build


After the plugin was written, before installing it, you will need to build it: mvn source: jar install -Dmaven.test.skip = true start in the project folder and get the jar in the target folder. We copied 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 mistakes: we look at the logs and correct them.

Source: https://habr.com/ru/post/64384/


All Articles