diff options
author | Alex Blewitt | 2020-06-02 21:02:28 +0000 |
---|---|---|
committer | Alex Blewitt | 2020-06-29 13:39:07 +0000 |
commit | 386e461afa5eefb733cb0a2ac864dc230b0fe05b (patch) | |
tree | b179aa3c993c498dc29df13458e612af5924b440 | |
parent | 11a09692b07fd57ba1e9e85f225edff215eb5a0f (diff) | |
download | eclipse.pde.ui-386e461afa5eefb733cb0a2ac864dc230b0fe05b.tar.gz eclipse.pde.ui-386e461afa5eefb733cb0a2ac864dc230b0fe05b.tar.xz eclipse.pde.ui-386e461afa5eefb733cb0a2ac864dc230b0fe05b.zip |
Bug 527378 - Final update removalI20200701-0330I20200630-1800
Remove all the remaining update manager references in the code from PDE
Core, and remove the now no longer referenced classes.
Change-Id: Iab8ce0db2686aa9469e21773ccda701fbc1fec84
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
4 files changed, 1 insertions, 362 deletions
diff --git a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF index f8a065679d..f5576f5faa 100644 --- a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF @@ -80,7 +80,6 @@ Require-Bundle: org.eclipse.e4.core.services;bundle-version="[2.0.0,3.0.0)", org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)", - org.eclipse.update.configurator;bundle-version="[3.1.0,4.0.0)", org.eclipse.text;bundle-version="[3.1.0,4.0.0)", org.eclipse.jdt.launching;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)", diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java index 09e7c84588..26a5b07bc3 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java @@ -14,12 +14,7 @@ package org.eclipse.pde.internal.core; import java.lang.reflect.InvocationTargetException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; import java.util.Hashtable; -import java.util.List; import org.eclipse.core.resources.ISaveContext; import org.eclipse.core.resources.ISaveParticipant; import org.eclipse.core.resources.IWorkspace; @@ -27,17 +22,14 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.URIUtil; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.osgi.service.debug.DebugOptions; import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.eclipse.pde.core.IBundleClasspathResolver; -import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.project.IBundleProjectService; import org.eclipse.pde.core.target.ITargetPlatformService; import org.eclipse.pde.internal.core.builders.FeatureRebuilder; @@ -46,7 +38,6 @@ import org.eclipse.pde.internal.core.project.BundleProjectService; import org.eclipse.pde.internal.core.schema.SchemaRegistry; import org.eclipse.pde.internal.core.target.P2TargetUtils; import org.eclipse.pde.internal.core.target.TargetPlatformService; -import org.eclipse.update.configurator.ConfiguratorUtils; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; @@ -80,7 +71,6 @@ public class PDECore extends Plugin implements DebugOptionsListener { // Shared instance private static PDECore inst; - private static IPluginModelBase[] registryPlugins; private static PDEExtensionRegistry fExtensionRegistry = null; /** @@ -190,34 +180,6 @@ public class PDECore extends Plugin implements DebugOptionsListener { inst = this; } - public IPluginModelBase findPluginInHost(String id) { - if (registryPlugins == null) { - URL[] pluginPaths = ConfiguratorUtils.getCurrentPlatformConfiguration().getPluginPath(); - URI[] paths = toUri(pluginPaths); - PDEState state = new PDEState(paths, false, false, new NullProgressMonitor()); - registryPlugins = state.getTargetModels(); - } - - for (IPluginModelBase plugin : registryPlugins) { - if (plugin.getPluginBase().getId().equals(id)) { - return plugin; - } - } - return null; - } - - private URI[] toUri(URL[] pluginPaths) { - List<URI> uris = new ArrayList<>(); - for (URL url : pluginPaths) { - try { - uris.add(URIUtil.toURI(url)); - } catch (URISyntaxException e) { - // ignore - } - } - return uris.toArray(new URI[0]); - } - public PluginModelManager getModelManager() { return PluginModelManager.getInstance(); } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java index 9b52debebc..6765db8098 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java @@ -19,28 +19,15 @@ import java.io.FileInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; import java.util.HashSet; import java.util.Properties; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; -import org.eclipse.osgi.service.datalocation.Location; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.update.configurator.ConfiguratorUtils; -import org.eclipse.update.configurator.IPlatformConfiguration; -import org.eclipse.update.configurator.IPlatformConfiguration.ISiteEntry; @SuppressWarnings("deprecation") // PDE still supports searching the platform.xml for plug-in/feature listings public class PluginPathFinder { - private static final String URL_PROPERTY = "org.eclipse.update.resolution_url"; //$NON-NLS-1$ - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - /** * * @param platformHome @@ -110,156 +97,8 @@ public class PluginPathFinder { return sites.toArray(new File[sites.size()]); } - /** - * Attempts to find all plugin paths if the target platform was at the given string location. - * <p> - * Should not be called in PDE. It should only be used to confirm test results match the - * old way of doing things (before ITargetPlatformService). - * </p> - * - * @param platformHome the target platform location - * @param installedOnly whether to check for a bundles.info or another configuration file to - * determine what bundles are installed rather than what bundles simply exist in the plugins folder - * @return list of URL plug-in locations - */ - public static URL[] getPluginPaths(String platformHome, boolean installedOnly) { - // If we don't care about installed bundles, simply scan the location - if (!installedOnly) { - return scanLocations(getSites(platformHome, false)); - } - - // See if we can find a bundles.info to get installed bundles from - URL[] urls = null; - if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation()))) { - // Pointing at default install, so use the actual configuration area - Location configArea = Platform.getConfigurationLocation(); - - if (configArea != null) { - urls = P2Utils.readBundlesTxt(platformHome, configArea.getURL()); - - // try the shared location (parent) - if (urls == null && configArea.getParentLocation() != null) { - urls = P2Utils.readBundlesTxt(platformHome, configArea.getParentLocation().getURL()); - } - } - - } else { - // Pointing at a folder, so try to guess the configuration area - File configurationArea = new File(platformHome, "configuration"); //$NON-NLS-1$ - if (configurationArea.exists()) { - try { - urls = P2Utils.readBundlesTxt(platformHome, configurationArea.toURL()); - } catch (MalformedURLException e) { - PDECore.log(e); - } - } - } - if (urls != null) { - return urls; - } - - if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation())) && !isDevLaunchMode()) { - return ConfiguratorUtils.getCurrentPlatformConfiguration().getPluginPath(); - } - - return getPlatformXMLPaths(platformHome, false); - } - public static URL[] getFeaturePaths(String platformHome) { - return getPlatformXMLPaths(platformHome, true); - } - - /** - * Returns a list of file URLs for plug-ins or features found in a platform.xml file or in the default - * directory ("plugins"/"features") if no platform.xml is available. - * - * @param platformHome base location for the installation, used to search for platform.xml - * @param findFeatures if <code>true</code> will return paths to features, otherwise will return paths to plug-ins. - * @return a list of URL paths to plug-ins or features. Possibly empty if the platform.xml had no entries or the default directory had no valid files - */ - public static URL[] getPlatformXMLPaths(String platformHome, boolean findFeatures) { - File file = getPlatformFile(platformHome); - if (file != null) { - try { - String value = new Path(platformHome).toFile().toURL().toExternalForm(); - System.setProperty(URL_PROPERTY, value); - try { - IPlatformConfiguration config = ConfiguratorUtils.getPlatformConfiguration(file.toURL()); - return getConfiguredSitesPaths(platformHome, config, findFeatures); - } finally { - System.setProperty(URL_PROPERTY, EMPTY_STRING); - } - } catch (IOException e) { - } - } - return scanLocations(getSites(platformHome, findFeatures)); - } - - /** - * Returns a File object representing the platform.xml or null if the file cannot be found. - * @return File representing platform.xml or <code>null</code> - */ - private static File getPlatformFile(String platformHome) { - String location = System.getProperty("org.eclipse.pde.platform_location"); //$NON-NLS-1$ - File file = null; - if (location != null) { - try { - IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); - location = manager.performStringSubstitution(location); - Path path = new Path(location); - if (path.isAbsolute()) { - file = path.toFile(); - } else { - file = new File(platformHome, location); - } - if (file.exists()) { - return file; - } - } catch (CoreException e) { - PDECore.log(e); - } - } - file = new File(platformHome, "configuration/org.eclipse.update/platform.xml"); //$NON-NLS-1$ - return file.exists() ? file : null; - } - - private static URL[] getConfiguredSitesPaths(String platformHome, IPlatformConfiguration configuration, boolean features) { - URL[] installPlugins = scanLocations(new File[] {new File(platformHome, features ? "features" : "plugins")}); //$NON-NLS-1$ //$NON-NLS-2$ - URL[] extensionPlugins = getExtensionPluginURLs(configuration, features); - - URL[] all = new URL[installPlugins.length + extensionPlugins.length]; - System.arraycopy(installPlugins, 0, all, 0, installPlugins.length); - System.arraycopy(extensionPlugins, 0, all, installPlugins.length, extensionPlugins.length); - return all; - } - - /** - * - * @param config - * @param features true for features false for plugins - * @return URLs for features or plugins on the site - */ - private static URL[] getExtensionPluginURLs(IPlatformConfiguration config, boolean features) { - ArrayList<URL> extensionPlugins = new ArrayList<>(); - IPlatformConfiguration.ISiteEntry[] sites = config.getConfiguredSites(); - for (ISiteEntry site : sites) { - URL url = site.getURL(); - if ("file".equalsIgnoreCase(url.getProtocol())) { //$NON-NLS-1$ - String[] entries; - if (features) { - entries = site.getFeatures(); - } else { - entries = site.getPlugins(); - } - for (String entry : entries) { - try { - extensionPlugins.add(new File(url.getFile(), entry).toURL()); - } catch (MalformedURLException e) { - } - } - } - } - return extensionPlugins.toArray(new URL[extensionPlugins.size()]); + return scanLocations(getSites(platformHome, true)); } /** @@ -285,18 +124,4 @@ public class PluginPathFinder { } return result.toArray(new URL[result.size()]); } - - public static boolean isDevLaunchMode() { - if (Boolean.getBoolean("eclipse.pde.launch")) { //$NON-NLS-1$ - return true; - } - String[] args = Platform.getApplicationArgs(); - for (String arg : args) { - if (arg.equals("-pdelaunch")) { //$NON-NLS-1$ - return true; - } - } - return false; - } - } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/UpdateManagerHelper.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/UpdateManagerHelper.java deleted file mode 100644 index aa5dcfe0f0..0000000000 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/UpdateManagerHelper.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.core; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Locale; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.internal.core.ifeature.IFeature; -import org.eclipse.pde.internal.core.ifeature.IFeatureModel; -import org.eclipse.update.configurator.ConfiguratorUtils; -import org.eclipse.update.configurator.IPlatformConfiguration; - -@SuppressWarnings("deprecation") -// The update manager is deprecated, but still supported in PDE launching -public class UpdateManagerHelper { - - private static class LocalSite { - private final ArrayList<IPluginModelBase> fPlugins; - private IPath fPath; - - public LocalSite(IPath path) { - if (path.getDevice() != null) { - fPath = path.setDevice(path.getDevice().toUpperCase(Locale.ENGLISH)); - } else { - fPath = path; - } - fPlugins = new ArrayList<>(); - } - - public IPath getPath() { - return fPath; - } - - public URL getURL() throws MalformedURLException { - return new URL("file:" + fPath.removeTrailingSeparator()); //$NON-NLS-1$ - } - - public void add(IPluginModelBase model) { - fPlugins.add(model); - } - - public String[] getRelativePluginList() { - String[] list = new String[fPlugins.size()]; - for (int i = 0; i < fPlugins.size(); i++) { - IPluginModelBase model = fPlugins.get(i); - IPath location = new Path(model.getInstallLocation()); - // defect 37319 - if (location.segmentCount() > 2) { - location = location.removeFirstSegments(location.segmentCount() - 2); - } - //31489 - entry must be relative - list[i] = location.setDevice(null).makeRelative().toString(); - } - return list; - } - } - - public static void createPlatformConfiguration(File configLocation, IPluginModelBase[] models, IPluginModelBase brandingPlugin) throws CoreException { - try { - IPlatformConfiguration platformConfiguration = ConfiguratorUtils.getPlatformConfiguration(null); - - // Compute local sites - ArrayList<LocalSite> sites = new ArrayList<>(); - for (IPluginModelBase model : models) { - IPath path = new Path(model.getInstallLocation()).removeLastSegments(2); - addToSite(path, model, sites); - } - - createConfigurationEntries(platformConfiguration, sites); - - if (brandingPlugin != null) { - createFeatureEntries(platformConfiguration, brandingPlugin); - } - - platformConfiguration.refresh(); - platformConfiguration.save(new URL("file:" + configLocation.getPath())); //$NON-NLS-1$ - } catch (Exception e) { - // Wrap everything else in a core exception. - String message = e.getMessage(); - if (message == null || message.length() == 0) { - message = PDECoreMessages.TargetPlatform_exceptionThrown; - } - throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, IStatus.ERROR, message, e)); - } - } - - private static void addToSite(IPath path, IPluginModelBase model, ArrayList<LocalSite> sites) { - if (path.getDevice() != null) { - path = path.setDevice(path.getDevice().toUpperCase(Locale.ENGLISH)); - } - for (int i = 0; i < sites.size(); i++) { - LocalSite localSite = sites.get(i); - if (localSite.getPath().equals(path)) { - localSite.add(model); - return; - } - } - // First time - add site - LocalSite localSite = new LocalSite(path); - localSite.add(model); - sites.add(localSite); - } - - private static void createConfigurationEntries(IPlatformConfiguration config, ArrayList<LocalSite> sites) throws MalformedURLException { - - for (int i = 0; i < sites.size(); i++) { - LocalSite localSite = sites.get(i); - String[] plugins = localSite.getRelativePluginList(); - - int policy = IPlatformConfiguration.ISitePolicy.USER_INCLUDE; - IPlatformConfiguration.ISitePolicy sitePolicy = config.createSitePolicy(policy, plugins); - IPlatformConfiguration.ISiteEntry siteEntry = config.createSiteEntry(localSite.getURL(), sitePolicy); - config.configureSite(siteEntry); - } - config.isTransient(true); - } - - private static void createFeatureEntries(IPlatformConfiguration config, IPluginModelBase plugin) throws MalformedURLException { - String id = plugin.getPluginBase().getId(); - IFeatureModel featureModel = PDECore.getDefault().getFeatureModelManager().findFeatureModel(id); - if (featureModel != null) { - IFeature feature = featureModel.getFeature(); - IPlatformConfiguration.IFeatureEntry featureEntry = config.createFeatureEntry(id, feature.getVersion(), id, plugin.getPluginBase().getVersion(), true, null, new URL[] {new URL("file:" + plugin.getInstallLocation())}); //$NON-NLS-1$ - config.configureFeatureEntry(featureEntry); - } - } - -} |