Developing a Jira Plugin and based on this Atlassian documentation Component import how can I import another component from an external plugin? Label Manager in this case, if anyone is familiar with it.
From their documentation, Label Manager recommends to import the component by adding this into the atlassian-plugin.xml:
but how can I use this component in my code? I can seem to find the component and use those external services. What’s the step after adding the component import tag?
Keep in mind that there’s no guarantee that third-party components will be marked as public in their <component> export, so this might not work.
Once you have declared in your atlassian-plugin.xml the appropriate <component-import>, you can then use it in your own classes using dependency injection. There are multiple ways to do that: two common examples are @Autowired and constructor injection.
@Component
public class FooBar {
@Autowired
private LabelITItemService labelItemService;
public doWhatever() {
labelItemService.something();
}
}
public class FooBar {
private final LabelITItemService itemService;
public FooBar(LabelITItemService itemService) {
this.itemService = itemService;
}
}