Jira plugin Java Spring Configuration fail to resolve dependency

Robert Bojtos January 26, 2021

Hi, 

I've started a plugin development from scratch and used atlas-create-jira-plugin command via the Atlassian sdk. I've chosen Spring Java Configuration as a main way to import components, following this documentation.  

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

The atlas-mvn package command worked and I was able to upload the app in jira instance and could develop the plugin continuously until yesterday.

Today the SpingConfig in which the bean configuration is stored, failed to import the static helper service "importOsgiService" by which I used to bring in and instantiate the beans. 

import static com.atlassian.plugins.osgi.javaconfig.OsgiServices.*;
public TemplateRenderer templateRenderer(){
return importOsgiService(TemplateRenderer.class);
}

To solve this, I tried to run atlas-mvn clean install and atlas-mvn clean package hoping it would resolve the dependency again.

Since then, maven is unable to resolve the dependency for com.atlassian.plugin:atlassian-plugins-osgi-javaconfg. 

The error in IntelliJ: 

No versions available for com.atlassian.plugins:atlassian-plugins-osgi-javaconfig:pom:[0.2.0,0.3.1) within specified range.

Any help or suggestion is appreciated. Just want to mention that I am new into the Spring world and know just the basics. 

Down below is the configuration in my pom.xml:

 

<?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.example.jira</groupId>
<artifactId>example-project-settings-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>

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

<name>example-project-settings-plugin</name>
<description>Provides functionality to view group members in Users and Roles page in jira Administration. </description>
<packaging>atlassian-plugin</packaging>

<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://packages.atlassian.com/content/repositories/atlassian-public/com/atlassian/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<dependencies>



<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>2.0.4</version>
<scope>provided</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version> <!-- fix for JIRA 7.x in order to bind to Servlet API 3.0 -->
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
<version>${osgi.javaconfig.version}</version>
<type>pom</type>
<scope>provided</scope>
</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>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</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>
<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.example.jira.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>8.13.1</jira.version>
<amps.version>8.1.0</amps.version>
<osgi.javaconfig.version>[0.2.0,0.3.0)</osgi.javaconfig.version>
<spring.version>5.0.10.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>
<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>

 

1 answer

0 votes
Robert Bojtos January 27, 2021

Found the answer on a post on stackoverflow. 

The dependency does not come directly from maven public repository, but instead of an atlassian repository. 

adding this to my pom.xml solved the issue: 

<repositories>
<repository>
<id>Atlassian</id>
<name>Atlassian Public</name>
<url>https://maven.atlassian.com/content/repositories/atlassian-public</url>
</repository>
</repositories>

Suggest an answer

Log in or Sign up to answer