Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
JIRA Development Cookbook

You're reading from   JIRA Development Cookbook Third Edition

Arrow left icon
Product type Paperback
Published in Sep 2016
Publisher
ISBN-13 9781785885617
Length 598 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Plugin Development Process FREE CHAPTER 2. Understanding the 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 the JIRA Database 11. Useful Recipes

Adding plugin modules

The plugin architecture is built around plugin modules, and JIRA exposes a number of plugin module types, each with a specific purpose. A plugin can have any number of plugin modules, either of the same type or of different types, as long as they all have a unique key. Throughout this book, we will see how we can use different plugin module types to solve different requirements.

In this recipe we will look at adding plugin modules to an existing plugin project.

Getting ready

Make sure the plugin project already exists or create a new skeleton project as explained, in the previous recipe.

How to do it...

  1. Open a command window and go to the plugin project folder, where pom.xml resides.

    Type atlas-create-jira-plugin-module and press Enter. This will show all the available plugin modules as a numbered list, as shown here:

    How to do it...
  2. Select the number against the module that you are planning to add. For example, type 25 and press Enter if you want to add a simple web-item module to the plugin.
  3. Follow the instructions to provide the details required for the selected module. Some of the options may have default values. Some modules might also have an advanced setup. Type Y and press Enter when prompted, if you want to go to Advanced Setup. If not, type N and press Enter.
  4. Once the module is completed, type Y or N and press Enter when prompted to add another plugin module, depending on whether you want to add another module or not.
  5. Repeat the steps for every module you want to add.
  6. Wait for the BUILD SUCCESSFUL message when no more modules are to be added.

How it works...

Similar to the skeleton plugin creation, a set of directories and subdirectories are created during this process, along with a number of Java files or velocity templates required for the selected plugin module.

It also adds the plugin module definition in the atlassian-plugin.xml based on our inputs in step 4. A sample plugin descriptor, after adding the web-item module, looks like this:

<?xml version="1.0" encoding="UTF-8"?> 
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2"> 
    <plugin-info> 
        <description>${project.description}</description> 
        <version>${project.version}</version> 
        <vendor name="${project.organization.name}"
          url="${project.organization.url}"/> 
        <param name="plugin-icon">images/pluginIcon.png</param> 
        <param name="plugin-logo">images/pluginLogo.png</param> 
    </plugin-info> 
    <!-- add our i18n resource --> 
    <resource type="i18n" name="i18n" location="demoplugin"/> 
    <!-- add our web resources --> 
    <web-resource key="demoplugin-resources" 
     name="demoplugin Web Resources"> 
        <dependency>com.atlassian.auiplugin:ajs</dependency> 
        <resource type="download" name="demoplugin.css" location="/css
          /demoplugin.css"/> 
        <resource type="download" name="demoplugin.js" location="/js
          /demoplugin.js"/> 
        <resource type="download" name="images/" location="/images"/> 
        <context>demoplugin</context> 
    </web-resource> 
    <web-item name="My Web Item" i18n-name-key="my-web-item.name" 
      key="my-web-item" section="system.user.options/personal" 
      weight="1000"> 
        <description key="my-web-item.description">The My Web Item Plugin
        </description> 
        <label key="my-web-item.label"></label> 
        <link linkId="my-web-item-link">http://www.j-tricks.com</link> 
    </web-item> 
</atlassian-plugin> 

As you can see, a web-item module is added. We will see more about the web-item module, and other modules mentioned here, in the upcoming chapters.

You can also see a resource module and a web-resource module, which are added automatically the first time a plugin module is created.

The resource module defines the i18n resource file for the plugin, and more key-value pairs will be added in to this file when more modules are added. The file has the name {plugin-artifact-name}.properties and is created under the src/main/resources{plugin-group-folder} folder. In our example, the demo.properties file is created under the src/main/resources/com/jtricks/demo folder.

A sample property file is as follows:

#put any key/value pairs here 
my.plugin.name=MyPlugin 
my-web-item.label=My Web Item 
my-web-item.name=My Web Item 
my-web-item.description=The My Web Item Plugin 

The web-resource module defines the plugin web resources, which includes a JS file, a CSS file, and an images folder that has the default plugin icon and logo images. We will learn more about these modules later in this book.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
JIRA Development Cookbook
You have been reading a chapter from
JIRA Development Cookbook - Third Edition
Published in: Sep 2016
Publisher:
ISBN-13: 9781785885617
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
Modal Close icon
Modal Close icon