Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian Honnen2020-10-01 08:18:45 +0000
committerJulian Honnen2020-10-02 07:58:02 +0000
commit87c008e3edd6715b9d4a4320417875042a917446 (patch)
tree256366958455862a6bc7b89c1c300de7275a6e1e
parentd4a49972c4610da37f102c8755a54e88d73f86b5 (diff)
downloadeclipse.pde.ui-87c008e3edd6715b9d4a4320417875042a917446.tar.gz
eclipse.pde.ui-87c008e3edd6715b9d4a4320417875042a917446.tar.xz
eclipse.pde.ui-87c008e3edd6715b9d4a4320417875042a917446.zip
Bug 566642 - restored parsing of platform.xml to find features
The information from org.eclipse.update/platform.xml is still required to find features that are located outside the installation directory. Change-Id: Ia395525f9a7f5ddd60699a205194023bd8afa989 Signed-off-by: Julian Honnen <julian.honnen@vector.com>
-rw-r--r--ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java87
1 files changed, 87 insertions, 0 deletions
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 6765db8098..5ebe515f75 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,15 +19,23 @@ 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.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.pde.internal.core.update.configurator.PlatformConfiguration;
+import org.eclipse.pde.internal.core.update.configurator.SiteEntry;
@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$
+
/**
*
* @param platformHome
@@ -98,11 +106,90 @@ public class PluginPathFinder {
}
public static URL[] getFeaturePaths(String platformHome) {
+ File file = getPlatformFile(platformHome);
+ if (file != null) {
+ try {
+ String value = new Path(platformHome).toFile().toURL().toExternalForm();
+ System.setProperty(URL_PROPERTY, value);
+ try {
+ PlatformConfiguration config = new PlatformConfiguration(file.toURL());
+ return getConfiguredSitesPaths(platformHome, config);
+ } finally {
+ System.setProperty(URL_PROPERTY, ""); //$NON-NLS-1$
+ }
+ } catch (Exception e) {
+ PDECore.log(e);
+ }
+ }
return scanLocations(getSites(platformHome, true));
}
/**
+ * 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, PlatformConfiguration configuration) {
+ URL[] installPlugins = scanLocations(new File[] { new File(platformHome, "features") }); //$NON-NLS-1$
+ URL[] extensionPlugins = getExtensionPluginURLs(configuration);
+
+ 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
+ * @return URLs for features or plugins on the site
+ */
+ private static URL[] getExtensionPluginURLs(PlatformConfiguration config) {
+ ArrayList<URL> extensionPlugins = new ArrayList<>();
+ SiteEntry[] sites = config.getConfiguredSites();
+ for (SiteEntry site : sites) {
+ URL url = site.getURL();
+ if ("file".equalsIgnoreCase(url.getProtocol())) { //$NON-NLS-1$
+ String[] entries = site.getFeatures();
+ for (String entry : entries) {
+ try {
+ extensionPlugins.add(new File(url.getFile(), entry).toURL());
+ } catch (MalformedURLException e) {
+ }
+ }
+ }
+ }
+ return extensionPlugins.toArray(new URL[extensionPlugins.size()]);
+ }
+
+ /**
* Scan given plugin/feature directories or jars for existence
+ *
* @param sites
* @return URLs to plugins/features
*/

Back to the top