Hello,
I’m relatively new to plugin development, and have been trying to build a Complex plugin with dependencies on another plugin. Therefore, from what I understand I need to leverage the Spring Scanner framework to inject dependencies between OSGi bundles so that I can get references to instances of runtime objects.
The problem I’m having is that for stuff such as Autowire and Component, the dependencies aren’t being pulled in at compile time and therefore when I try to execute the jira:run goal it of course fails while packaging.
I know I need to specify the package imports in the maven-jira-plugin osgi instructions, and have. However, what confuses me is how I should include the dependencies in the dependencies part of the POM.
Is there a parent POM I’m supposed to be depending on, that should pull in those dependencies? Or am I supposed to somehow find the group/artifact and the version in the runtime and pull in those (specifying them manually in …)?
I’ve been through most of the Developer documentation, through Bitbucket but am very much struggling with finding a consistent answer that gets me to at least running code for the past several days.
Any help you can offer to help me wrap my head around this would be greatly appreciated – thanks in advance!
Also, here is my example POM for reference / as a talking point:
<?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</groupId>
<artifactId>myplugin</artifactId>
<version>1.0.0</version>
<organization>
<name>Tina</name>
<url>https://example.com</url>
</organization>
<name>Example Plugin</name>
<description>This plugin has a dependency on a marketplace plugin</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>${com.atlassian.sal.api.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.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<!--<scope>compile</scope>-->
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
-->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</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>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5</version>
<scope>provided</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>
<scope>compile</scope>
</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>
-->
<!-- Third Party Plugin Dependencies -->
<dependency>
<groupId>com.somecompany</groupId>
<artifactId>marketplaceplugin</artifactId>
<version>${com.somecompany.marketplaceplugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<jvmArgs>-Xms2g -Xmx4g -XX:MaxPermSize=4g -XX:-UseGCOverheadLimit -server</jvmArgs>
<applications>
<!-- Include Jira Software features -->
<application>
<applicationKey>jira-software</applicationKey>
<version>${jira.version}</version>
</application>
</applications>
<!-- 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>
<enableFastdev>false</enableFastdev>
<!-- 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.myplugin*</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
com.atlassian.jira.*;resolution="optional",
com.atlassian.sal.api.*;resolution:="optional",
com.somecompany.marketplaceplugin.*;version=${com.somecompany.marketplaceplugin.version};resolution="optional",
org.springframework.beans.factory.annotation.*;resolution="optional",
org.springframework.stereotype*;resolution="optional",
*
</Import-Package>
<Require-Bundle>
com.somecompany.marketplaceplugin;bundle-version="[${com.somecompany.marketplaceplugin.version},${com.somecompany.marketplaceplugin.version}]"
</Require-Bundle>
<CONF_COMM/>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
<pluginDependencies>
<dependency>
<groupId>com.somecompany</groupId>
<artifactId>marketplaceplugin</artifactId>
</dependency>
</pluginDependencies>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>7.10.2</jira.version>
<com.atlassian.sal.api.version>3.1.0</com.atlassian.sal.api.version>
<com.somecompany.marketplaceplugin.version>1.2.3</com.somecompany.marketplaceplugin.version>
<amps.version>6.3.21</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>2.1.8</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<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>