Getting List of active user plugins from custom content provider

Hello dear friends.

I need to access a list of active user plugins from our own plugin. Is it actually possible?

Background:

We have two custom plugins.

Plugin A provides a web panel on issue view. Along with its primary features, it is supposed to render additional information under condition that another custom Plugin B is installed and active. But we dont want to have a dependency between A and B because B is completely optional and A should work without B.

Is there a possibility to find out wether plugin B is installed and active from plugin A content provider?

2 answers

1 accepted

looks like i have found a solution.

public class APluginContentProvider extends AbstractJiraContextProvider {

	private final static String PLUGIN_B_KEY = "com.vendor.group.pluginB";
	private final PluginAccessor plugins;
	private boolean bPluginActive = false;	// false by default

	public APluginContentProvider(final PluginAccessor plugins) {
		// inject plugin accessor
		this.plugins = plugins;	
	}

	public Map getContextMap(final User user, final JiraHelper jiraHelper) {

		// check if plugin B is installed and enabled using plugin accessor
		final Plugin pluginB = plugins.getEnabledPlugin(PLUGIN_B_KEY);
		if (pluginB != null) {
			log.debug("found plugin B" + pluginB.getKey());
			bPluginActive = true;
		}
		contextMap.put("bPluginActive", bPluginActive);
		return contextMap;
	}
}

my first guess would be to use com.atlassian.plugin.manager.DefaultPluginManager

this seems to be the right component to control plugins. However it does not implement any interface and cannot be constructor injectted. Any ideas?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 7 hours ago in Hipchat

Moving from Hipchat to Stride? Here’s what you’ll love

Heya, Hipchat friends! We’re so happy you’re checking out   Stride. Whether you know it or not, you have been instrumental in making Stride come to life. Every feature, design, and functionality...

30 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you