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
.