Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
JIRA Development Cookbook

You're reading from   JIRA Development Cookbook Develop and customize plugins, program workflows, work on custom fields, master JQL functions, and more to effectively customize, manage, and extend JIRA

Arrow left icon
Product type Paperback
Published in Nov 2011
Publisher Packt
ISBN-13 9781849681803
Length 476 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jobin Kuruvilla Jobin Kuruvilla
Author Profile Icon Jobin Kuruvilla
Jobin Kuruvilla
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

JIRA Development Cookbook
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
1. Plugin Development Process FREE CHAPTER 2. Understanding Plugin Framework 3. Working with Custom Fields 4. Programming Workflows 5. Gadgets and Reporting in JIRA 6. The Power of JIRA Searching 7. Programming Issues 8. Customizing the UI 9. Remote Access to JIRA 10. Dealing with a Database 11. Useful Recipes Index

Creating a skeleton plugin


In this recipe, we will look at creating a skeleton plugin. We will use the Atlassian Plugin SDK to create the skeleton!

Getting ready

Make sure you have the Atlassian Plugin SDK installed and a version of JIRA 4.x running on your local machine.

How to do it...

  1. Open a command window and go to the folder where you want to create the plugin.

    Note

    Make sure you use a directory without any spaces because there are known issues with the SDK not working in directories with spaces in it. See https://studio.atlassian.com/browse/AMPS-126 for details.

  2. Type atlas-create-jira-plugin and press Enter.

  3. Enter the groupID when prompted. GroupID would normally be coming from your organization name and mostly resembles the Java package. Of course, you can enter a different package name as we move forward if you want to keep it separate. GroupID will be used to identify your plugin along with artifactId.

    For example: com.jtricks.demo.

  4. Enter the artifactId—the identifier for this artifact. Do not use spaces here.

    For example: demoplugin.

  5. Version—the default version is 1.0-SNAPSHOT. Enter a new version if you want to change it or press Enter to keep the default.

    For example: 1.0

  6. Package—press Enter if the package value is same as the groupID. If not, enter the new value here and press Enter.

    For example, com.jtricks.mypackage

  7. Confirm the selection when prompted. If you want to change any of the entered values, type N and press Enter.

  8. Wait for the BUILD SUCCESSFUL message. You might see a few warnings which can be ignored.

How it works...

A skeleton plugin is nothing but a set of directories and sub directories along with a pom.xml (Maven Project Object Model) file and some sample Java and XML files in the appropriate folders.

Here is a snapshot of how the project will look like in Eclipse. It also shows the design view of the default atlassian-plugin.xml file:

As you can see, there is a pom.xml at the root level and a src folder. A sample LICENSE file and a README file are also created for you at the root level.

Under the src folder, you will find out two folders, main and test, with identical folder structure. All your main Java code goes under the main folder. Any JUnit tests you write will go into the same location under the test folder. There is an additional folder, it, under the test folder where all the integration tests will go!

You will find the plugin descriptor under src/main/resources with sample values already populated in it. The values in the preceding screenshot are populated from the pom.xml. In our case, the plugin key will be populated as com.jtricks.demo:demoplugin when the plugin is built.

There are two more folders under the src/test. src/test/resources, which will hold any resources required for unit tests or integration tests, and the src/test/xml folder can hold the XML data from any other JIRA instance. If the XML is supplied, the SDK will use it to configure the JIRA instance before running the integration tests.

So, that is our plugin Skeleton. All that is pending is some useful Java code and proper module types in the atlassian-plugin.xml file!

Note

Remember, the first Maven run is going to take some time as it downloads all the dependencies into your local repository. A coffee break might not be enough!! If you have a choice, plan your meals. ;)

There's more...

Sometimes, for the geeks, it is much easier to run a single command to create a project without bothering about the step-by-step creation. In this section, we will quickly see how to do it. We will also have a look at how to create an Eclipse project if you opt out of installing m2eclipse.

One step to your skeleton plugin

You can ignore the interactive mode by passing the parameters like groupID, artifactId, and so on, as arguments to the atlas-create-jira-plugin command.

atlas-create-jira-plugin -g my_groupID -a my_artefactId -v my_version -p my_package –non-interactive

In this example, for the values we saw previously, the single line command will be:

atlas-create-jira-plugin -g com.jtricks.demo -a demoplugin -v 1.0 -p com.jtricks.mypackage –non-interactive

You can pick and choose the parameters and provide the rest in an interactive mode as well!

Creating an Eclipse project

If you are not using m2eclipse, just run the following command from the folder where you have the pom.xml file:

atlas-mvn eclipse:eclipse

This will generate the plugin project for Eclipse and you can then import this project into the IDE.

Type atlas-mvn eclipse:clean eclipse:eclipse if you want to clean the old project and create again!

With IDEA or m2eclipse, just opening a file will do. That is, you can just import the project using the option File | Import | Existing Maven Projects, and select the relevant project.

See also

  • Deploying a plugin

  • Making changes and re-deploying a plugin

You have been reading a chapter from
JIRA Development Cookbook
Published in: Nov 2011
Publisher: Packt
ISBN-13: 9781849681803
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image