private File getP2BridgePluginDir() { try { final GAVCoordinate pluginGav = getP2BridgePluginGAV(); final PluginRepositoryArtifact pluginArtifact = pluginRepositoryManager.resolveArtifact(pluginGav); return pluginArtifact.getFile().getParentFile(); } catch (final NoSuchPluginRepositoryArtifactException e) { throw new IllegalStateException("Could not locate nexus-p2-bridge-plugin", e); } }
private void activatePlugin( final PluginRepositoryArtifact plugin, final PluginManagerResponse response, final Set<GAVCoordinate> installedPluginsFilteredByGA) throws NoSuchPluginRepositoryArtifactException { final GAVCoordinate pluginGAV = plugin.getCoordinate(); final PluginMetadata metadata = plugin.getPluginMetadata(); final PluginDescriptor descriptor = new PluginDescriptor(pluginGAV); descriptor.setPluginMetadata(metadata); final PluginResponse result = new PluginResponse(pluginGAV, PluginActivationRequest.ACTIVATE); result.setPluginDescriptor(descriptor); activePlugins.put(pluginGAV, descriptor); final List<GAVCoordinate> importList = new ArrayList<GAVCoordinate>(); final List<GAVCoordinate> resolvedList = new ArrayList<GAVCoordinate>(); for (final PluginDependency pd : metadata.getPluginDependencies()) { // here, a plugin might express a need for GAV1, but GAV2 might be already activated // since today we just "play" dependency resolution, we support GA resolution only // so, we say "relax version matching" and rely on luck for now it will work final GAVCoordinate gav = new GAVCoordinate(pd.getGroupId(), pd.getArtifactId(), pd.getVersion()); final PluginManagerResponse dependencyActivationResponse = activatePlugin(gav, false, installedPluginsFilteredByGA); response.addPluginManagerResponse(dependencyActivationResponse); importList.add(dependencyActivationResponse.getOriginator()); resolvedList.add(dependencyActivationResponse.getOriginator()); } descriptor.setImportedPlugins(importList); descriptor.setResolvedPlugins(resolvedList); if (!response.isSuccessful()) { result.setAchievedGoal(PluginActivationResult.BROKEN); } else { try { createPluginInjector(plugin, descriptor); result.setAchievedGoal(PluginActivationResult.ACTIVATED); } catch (final Throwable e) { result.setThrowable(e); } } reportActivationResult(response, result); }
void createPluginInjector( final PluginRepositoryArtifact plugin, final PluginDescriptor descriptor) throws NoSuchPluginRepositoryArtifactException { final String location = "reference:" + plugin.getFile().getParentFile().toURI(); try { systemBundleProvider.get().getBundleContext().installBundle(location).start(); } catch (BundleException e) { throw new IllegalStateException("Problem installing: " + location, e); } }