Getting started with developing Jira Datacenter apps, using the SDK

dconroy82 September 13, 2021

Hello,

I'm just getting started with the Atlassian SDK to attempt to develop some apps for Jira Datacenter.

I'm not new to programming and scripting - I've written hundreds of groovy scripts, and classes using Scriptrunner, and I've done a fair amount of .NET development in the past, but never Java, and this is my first time trying to write a real app.

My aim is to just get one of the tutorial apps to work 100%, and then start modifying it to learn.

I'm following the various Atlassian tutorials to get started, but they seem kind of outdated, and there are some discrepancies that are making it kind of confusing to get started. Also, I'm apparently using the latest SDK, but it auto-sets the Jira version to 7.13, which is way out of date, which seems odd. I just feel like I'm missing something (I know you can adjust the version after the fact)

 

I'm wondering if anyone has answers to some of these questions.

PS I'm initially trying the Helloworld tutorial, and the custom field tutorial 

 

1. When running  atlas-create-jira-plugin, there is an extra question, in addition to the ones listed in the tutorials that says "Use OSGi Java Config: (Y/N/y/n) N:" I'm not sure what this means, or if I should select Y or N.

It's not mentioned in any of the tutorials I've seen so far.

 

2. After creating the plugin structure using atlas-create-jira-plugin, there are immediate errors in the "build" panel of intelliJ IDEA:

Cannot resolve com.atlassian.plugins:atlassian-plugins-osgi-testrunner:2.0.2
Cannot resolve com.google.code.gson:gson:2.2.2-atlassian-1
Cannot resolve com.atlassian.jira:jira-api:7.13.0
Cannot resolve com.atlassian.plugins:atlassian-plugins-osgi-javaconfig:0.2.0

 

The project builds and runs, but it doesn't seem right that these errors would be there right away from a freshly generated project.

 

 

I had some other issues too, but I'll stop here for right now, to see if I can get the basics figured out first :)

 

I'm working on MacOS 11.5.2, with intelliJ IDEA community edition 2021.2.1

atlas-version command outputs the following:

 

Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T11:33:14-07:00)
Maven home: /Applications/Atlassian/atlassian-plugin-sdk-8.2.7/apache-maven-3.5.4
Java version: 1.8.0_301, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"
 

The SDK is 8.2.7.

 

The pom.xml created by a basic atlas-create-jira-plugin looks like this:

 
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.atlassian.tutorial</groupId>
<artifactId>myPlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>

<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>

<name>myPlugin</name>
<description>This is the com.atlassian.tutorial:myPlugin plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>

<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
<version>${osgi.javaconfig.version}</version>
</dependency>
<!-- OSGi Java Config dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>provided</scope>
</dependency>

<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>

<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>jira-maven-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>

<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

<!-- Add package to export here -->
<Export-Package>
com.atlassian.tutorial.myPlugin.api,
</Export-Package>

<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>

<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<properties>
<jira.version>7.13.0</jira.version>
<amps.version>8.1.2</amps.version>
<plugin.testrunner.version>2.0.2</plugin.testrunner.version>
<osgi.javaconfig.version>0.2.0</osgi.javaconfig.version>
<spring.version>4.2.5.RELEASE</spring.version>
<!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

</project>

 

Thanks for any help you can provide.

 

Also, if you have any specific sites (other than Atlassian) that may have more up to date guides or reading material for this stuff, that would be appreciated.

 

Thanks!

Dan 

1 answer

1 accepted

2 votes
Answer accepted
dconroy82 September 14, 2021

I did some more research and found a solution to one of my questions. The unresolvable dependencies were caused by the intelliJ bundled maven version.

 

I went to Preferences > Build, Execution, Deployment > Build Tools > Maven and set the maven version to

/Applications/atlassian-plugin-sdk-8.2.7/apache-maven-3.5.4 (the one included with the SDK), and that allowed it to resolve the dependencies.

 

I'm still unsure about what the question about the OSGi Java Config means, and why the SDK seems to be so out of date.

William Lupton November 15, 2021

> I'm still unsure about what the question about the OSGi Java Config means

+1

Given that "N" was the default I just accepted it, but I too didn't know what it meant!

Kru March 16, 2022

OSGI let you use Java Configuration along with Helper methods from OSGI layer of Atlassian. This enables us to export and import beans across services. I hope this link and the video from camp would help to understand it better

https://developer.atlassian.com/server/framework/atlassian-sdk/spring-java-config/

Suggest an answer

Log in or Sign up to answer