Quick start guide for creating a portlet plugin - deprecated

Deprecated:

In JIRA 4.0, portlets were replaced by gadgets. For details, please see Gadgets and JIRA Portlets.
In JIRA 5.0, all portlet-specific code has been removed from JIRA plugin points and APIs. See Java API Changes in JIRA 5.0.

Goal

This page is intended to get you up and running with writing your own JIRA portlet within no time.  It actually is a combination of several examples included in the plugin development kit which were broken.   The portlet which is explained below lets you configure 3 parameters and will result in table of books that match the searchcriterium:

  1. subscriptionId (Needed to use an Amazon webservice)
  2. searchParameter  (What book property will we be looking for ? E.g. Title, Author, ...)
  3. searchArgument (The argument which will be searched for.  E.g. "Java"  or "Ruby") 

    Screenshot 1: Configuration of portlet
     

    Screenshot 2: result of search (parameter = 'Author' & argument = 'Sierra')
     

    Screenshot 3: result of search (parameter = 'Title' & argument = 'Java')

Prequisites

My installed software:

  1. JDK 1.6.0_03
  2. Eclipse 3.3.0 
  3. Maven 2.0.7
  4. Jira enterprise edition 3.12.2

Configuration steps

You will need to make some changes to your $maven_home/conf/settings.xml.

   <profiles>
    <profile>
      <id>Ciber</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>

      <repositories>
        ...
        <!-- JIRA -->
        <repository>
          <id>atlassian-public</id>
          <url>https://maven.atlassian.com/repository/public</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
        <repository>
          <id>atlassian-contrib</id>
          <url>https://maven.atlassian.com/contrib</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
        <repository>
          <id>atlassian-m1-repository</id>
          <url>https://maven.atlassian.com/maven1</url>
          <layout>legacy</layout>
        </repository>
      </repositories>

      <pluginRepositories>
        ...
        <!-- JIRA -->
        <pluginRepository>
          <id>atlassian-public</id>
          <url>https://maven.atlassian.com/repository/public</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
        <pluginRepository>
          <id>atlassian-contrib</id>
          <url>https://maven.atlassian.com/contrib</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <releases>
            <enabled>true</enabled>
          </releases>
       </pluginRepository>
      </pluginRepositories>

      <properties>
        <downloadSources>false</downloadSources>
        <downloadJavadocs>false</downloadJavadocs>
        <atlassian.pdk.server.url>http://localhost:8080</atlassian.pdk.server.url>
        <atlassian.pdk.server.username>********</atlassian.pdk.server.username>
        <atlassian.pdk.server.password>********</atlassian.pdk.server.password>
      </properties>
    </profile>
  </profiles>

See also how to build an Atlassian plugin.

Next we will create a new plugin project based on a plugin archetype.  In a DOS-box, run following command:

 mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create \
  -DarchetypeGroupId=com.atlassian.maven.archetypes \
  -DarchetypeArtifactId=jira-plugin-archetype \
  -DarchetypeVersion=10 \
  -DremoteRepositories=https://maven.atlassian.com/repository/public/ \
  -DgroupId=$MY_PACKAGE$ -DartifactId=$MY_PLUGIN$

and replace $MY_PACKAGE$ and $MY_PLUGIN$ according to your project. Make sure you remove the backslashes "\" so the complete command is one 1 line before you execute it.

Maven will create a new folder $MY_PLUGIN$ and provide some default files. Check the JIRA:attachment for how the plugin works.

Cheers,

Robby

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport