Thanks for the help! I initially tried using that tutorial, but atlas-run would not work with <component> or <component-import> in the atlassian-plugin.xml file. The fix for this would seem to be using Spring Scanner annotations which can be seen above using @ComponentImport
I think I have solved most of my problems. The first thing I had to do was make the dependencies I added <scope>provided</scope>. Next I also had to add public void onIssueEvent(IssueEvent) to my Listener class for some reason I am not quite aware of.
I am now trying to create an Issue type upon installation or enabling of my plugin. Here is my code:
@Component
public class PluginListener implements InitializingBean, DisposableBean {
private static final Logger log = LoggerFactory.getLogger(PluginListener.class);
@ComponentImport
private final EventPublisher eventPublisher;
@ComponentImport
private final IssueTypeManager issueTypeManager;
@Inject
public PluginListener(EventPublisher eventPublisher, IssueTypeManager issueTypeManager) {
this.eventPublisher = eventPublisher;
this.issueTypeManager = issueTypeManager; works
}
public void afterPropertiesSet() throws Exception {
eventPublisher.register(this);
issueTypeManager.createIssueType("NewIssue", "This is the description", 0L); // This line only sometimes
// ^^^
}
public void destroy() throws Exception {
eventPublisher.unregister(this);
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
return;
}
}
Once I add the above indicated line, Jira fails to even start after doing atlas-mvn clean and then altas-run. When I add the code to an initial jira plugin setup the plugin times out when I run atlas-run again. I can get it to work however if I disable the plugin in the manager while keeping it running, add the line of code, then enable the plugin. My question is twofold:
What is the proper way to create an IssueType to be packaged with the plugin, making sure the type does not already exist?
What is the best way to debug this stuff so I can stop bugging you all?
You should find issuetypes by name and try to locate yours. Then you should store the ID of the issuetype somewhere so you can more easily retrieve it, even if the user renames it.
I find that it’s best to try and install the plugin at runtime to figure these issues out; When you install it at runtime the stdout should print the problem more deliberately. You’re likely getting an error right now, but it’s hidden in the jira startup logging as well.
Often I simply upload the plugin again will show me the stacktrace I needed to fix my issue.
Hi Teddy,
In debugging, kindly check the logs for related stack traces (if any) or any error logs. Usually, they are informative enough to point us in the right direction.
afterPropertiesSet Gets called the moment that the addon is initialized - the rest of the system might not be ready yet. Take a look at sal’s lifecycleaware - that should be triggered once the app and the system is ready.
As far as the event - make sure to annotate the class with @ExportAsService - event listeners has to be public components.