// disable custom plugins configured via properties, if they are already loaded
Set<String> disabledPlugins = corePreferences.getCustomPlugins(false);
Map<URI, Plugin> allPlugins = Plugin.getAllPluginsMap();
for (Entry<URI, Plugin> entry : allPlugins.entrySet()) {
Plugin fbPlugin = entry.getValue();
String pluginId = fbPlugin.getPluginId();
// ignore all custom plugins with the same plugin id as already loaded
if(contributedDetectors.containsKey(pluginId)) {
contributedDetectors.remove(pluginId);
detectorPaths.remove(pluginId);
}
if (fbPlugin.isCorePlugin() || fbPlugin.isInitialPlugin()) {
continue;
}
if (disabledPlugins.contains(entry.getKey().getPath())
|| disabledPlugins.contains(pluginId)) {
fbPlugin.setGloballyEnabled(false);
Plugin.removeCustomPlugin(fbPlugin);
if (DEBUG) {
System.out.println("Removed plugin: " + fbPlugin + " loaded from " + entry.getKey());
}
}
}
HashSet<Plugin> enabled = new HashSet<Plugin>();
// adding FindBugs *Eclipse* plugins, key plugin id, value is path
for (Entry<String, String> entry : contributedDetectors.entrySet()) {
String pluginId = entry.getKey();
String pluginPath = entry.getValue();
URI uri = new File(pluginPath).toURI();
if (disabledPlugins.contains(pluginId)
|| disabledPlugins.contains(pluginPath)
|| allPlugins.containsKey(uri)) {
continue;
}
addCustomPlugin(enabled, uri);
}
// adding custom plugins configured via properties, but only if they are not loaded yet
for (String path : detectorPaths) {
// this is plugin id, so we can't use it as URL
if(new Path(path).segmentCount() == 1) {
continue;
}
URI uri = new File(path).toURI();
if(allPlugins.containsKey(uri)) {
continue;
}
ValidationStatus status = validator.validate(path);
if (status.isOK()) {
addCustomPlugin(enabled, uri);
} else {
getDefault().getLog().log(status);
}
}
if (DEBUG) {
System.out.println("applyCustomDetectors - there was " + detectorPaths.size()
+ " extra FB plugin urls with " + enabled.size()
+ " valid FB plugins and " + allPlugins.size()
+ " total plugins registered by FB.");
for (Entry<URI, Plugin> entry : allPlugins.entrySet()) {
Plugin fbPlugin = entry.getValue();
if (fbPlugin.isGloballyEnabled()) {
System.out.println("IS enabled:\t" + fbPlugin.getPluginId());
} else {
System.out.println("NOT enabled:\t" + fbPlugin.getPluginId());
}
}
}
}