Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Communication between two plugins

Rui Rodrigues
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2015

Hi There,
There is a plugin that provides a component for integration. I want to communicate with that. So, What I need to communicate with that? I need to add the dependency on the pom.xml, but if the plugin that I want to communicate is not installed? I want that my plugin works if the other plugin is not installed.

Thank you.

Cheer,

RMRodrigues

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 12, 2015

Hi,

There is an excellent presentation by an Atlassian engineer on how to bundle and deploy cross-plugin dependencies.  It's called "You've got plugins in your plugins: Bundling Plugin Dependencies" and in my opinion it's the best way to learn how to do this from scratch, rather than reading the documentation on this stuff.

https://summit.atlassian.com/archives/2012/plugin-dev/plugins-in-your-plugins

https://www.youtube.com/watch?v=AzLCmMZ10fw

Rui Rodrigues
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

Hi @Joe Clark [Atlassian] , Thank you for your answer. I would like to know if it's possible to install my plugin(it depends of other plugin) without the other plugin to be installed on JIRA. I don't want to install it. Thank you. Cheers, RMRodrigues.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 14, 2015

If you watch the presentation, it will show you how to embed the other plugin _inside_ your plugin so that it will be installed automatically. If you want your plugin to function even when the other plugin is not present, then you will need to lazy-load your dependencies on the other plugin. You can do this by following this guide: https://developer.atlassian.com/docs/faq/advanced-plugin-development-faq/detecting-the-presence-or-absence-of-classes-in-different-osgi-bundles Even though it has a warning at the top, it is still the most reliable way of doing this that I'm aware of.

Rui Rodrigues
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 16, 2015

Thank you. It's almost perfect. I've a problem. When my plugin is installed and the other is being installed, the setBundleContext is invoked and a ClassNotFoundException occurs because that class belongs to other plugin. I've a dependency of other plugin on my pom.xml but the scope is "provided". Any Suggestion? Cheers, RMRodrigues

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 19, 2015

In your setBundleContext method, you cannot refer to the class in the other plugin until you are certain that the other plugin has been installed (for example, in the "addingService" method). Otherwise you will get a ClassNotFoundException.

Rui Rodrigues
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2015

Hi Joseph. I'm using that: public Object addingService(ServiceReference serviceReference) { logger.info("addingService"); setEnabled(true); return (ServiceFromAnotherPlugin) bundleContext.getService(serviceReference); } When the method addingService is invoked a ClassNotFoundException is thrown. ServiceFromAnotherPlugin is the service that belongs to the other plugin. It occurs when the other plugin is installed. Many thanks for your feedback. Cheers, RMRodrigues

Rui Rodrigues
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2015

hi Joseph, There is another problem. When the other plugin is uninstalled my plugin is disabled. Is that normal? Thank you.

Leon Liu (ease solutions) July 21, 2016

The page at https://developer.atlassian.com/docs/faq/advanced-plugin-development-faq/detecting-the-presence-or-absence-of-classes-in-different-osgi-bundles highlighted that the approach has a problem, and Atlasssian is working for a better solution.

May I know what is the problem by using this approach, and is there a better solution is found? 

Thanks in advance

Leon

TAGS
AUG Leaders

Atlassian Community Events