Adding plugin modules
In this recipe, we will look at adding plugin modules into 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…
Following are the steps to add plugin modules into an existing plugin project:
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 in the following screenshot: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.
Follow the instructions to provide details required for the selected module. Some of the options may have default values.
Note
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.
Once the module is completed, type Y or N and press Enter when prompted, depending on whether you want to add another module or not.
Repeat the steps for every module you want to add.
Wait for the BUILD SUCCESSFUL message to appear when no more modules are there to be added.
How it works…
Similar to the skeleton plugin creation, a set of directories and subdirectories are created during the process of adding plugin modules, 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
file based on our inputs in step 4. A sample plugin descriptor, after adding the Web Item module, is shown as follows:
<?xml version="1.0" encoding="UTF-8"?> <atlassian-plugin key="${project.groupId}.${project.artifactId}" 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}"/> </plugin-info> <resource type="i18n" name="i18n" location="com.jtricks.demo.demoplugin"/> <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. You can also see a resource
module, which is added automatically the first time a plugin module is created. This will be the i18n resource file for the plugin, and more key-value pairs will be added into 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, a demo.properties
file is created under the src/main/resources/com/jtricks/demo
folder.
A sample property file is shown as follows:
my-web-item.label=J-Tricks my-web-item.name=My Web Item my-web-item.description=The My Web Item Plugin
See also
The Creating a skeleton plugin recipe
The Deploying a JIRA plugin recipe
The Making changes to and redeploying a plugin recipe