Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set

This is what I get when I run atlas-create-jira-plugin followed by atlas-create-jira-plugin-module selecting option 1: Component Import.

The problem is that all tutorial examples appear to have plugin descriptor generated by old SDK version (that won't deploy with newer versions of SDK/Jira at all), which do not feature Atlassian-Plugin-Key, so I can't find my way to import a component.

I'm using SDK 6.2.3 and Jira 7.1.1.

Any hint - how to get this sorted out?

like image 530
tishma Avatar asked Mar 15 '16 10:03

tishma


3 Answers

anonymous is correct. The old way of doing things was to to put the <component-import> tag in your atlassian-plugin.xml. The new way and also recommended is to use Atlassian Spring Scanner. When you create your add-on using atlas-jira-create-plugin and your pom.xml has the <Atlassian-Plugin-Key> tag and the dependencies atlassian-spring-scanner-annotation and atlassian-spring-scanner-runtime then you are using the new way.

If you have both the dependencies, you are using Atlassian Spring Scanner version 1.x. If you only have atlassian-spring-scanner-annotation then you are using version 2.x.

You don't have to omit/comment out Atlassian-Plugin-Key in your pom.xml and you don't have to put component-import in your atlassian-plugin.xml.

For example, you want to add licensing for your add-on and need to import the component PluginLicenseManager. You just go straight to the code and your constructor might look like this:

@Autowired
public MyMacro(@ComponentImport PluginLicenseManager licenseManager) {
    this.licenseManager = licenseManager;
}

And your class like this:

@Scanned
public class MyMacro implements Macro {

If memory serves me right, be sure to check for null because sometimes Atlassian Spring Scanner can't inject a component. I think on version 1, writing an @EventListener, it could not inject a ConversionContext. But when writing a Macro, it was able to inject a ConversionContext.

like image 142
jpllosa Avatar answered Sep 23 '22 07:09

jpllosa


Found answer here: https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins

It looks like I've somehow been missing that Atlassian-Plugin-Key can be omitted, and it must be done when you need to import components.

This key just tells spring not to 'transform' plugin's Spring configuration, which must happen as part of components import process..

like image 24
tishma Avatar answered Sep 24 '22 07:09

tishma


According to https://bitbucket.org/atlassian/atlassian-spring-scanner

component-import is not needed. You can replace it by @ComponentImport annotation in your Java.

like image 31
anonymous Avatar answered Sep 26 '22 07:09

anonymous