Blame SOURCES/eclipse-pde-tp-support-droplets.patch

dc388e
From 7843458db4b359cbee040c17ddda21d5fa6ddd35 Mon Sep 17 00:00:00 2001
dc388e
From: Roland Grunberg <rgrunber@redhat.com>
dc388e
Date: Thu, 7 Apr 2016 10:23:49 -0400
dc388e
Subject: [PATCH] Support reading BundleInfo from p2 Droplets enabled
dc388e
 installations.
dc388e
dc388e
- Additionally support reading source bundles from p2 Droplets location
dc388e
---
dc388e
 .../org.eclipse.pde.core/META-INF/MANIFEST.MF |  1 +
dc388e
 .../eclipse/pde/internal/core/P2Utils.java    | 50 +++++++++++++++++--
dc388e
 2 files changed, 46 insertions(+), 5 deletions(-)
dc388e
dc388e
diff --git a/eclipse.pde.ui/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/eclipse.pde.ui/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
dc388e
index f045abd5b..864665785 100644
dc388e
--- a/eclipse.pde.ui/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
dc388e
+++ b/eclipse.pde.ui/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
dc388e
@@ -102,5 +102,6 @@ Require-Bundle:
dc388e
  org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)"
dc388e
 Eclipse-LazyStart: true
dc388e
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
dc388e
+Import-Package: org.eclipse.equinox.internal.simpleconfigurator.utils
dc388e
 Bundle-ActivationPolicy: lazy
dc388e
 Automatic-Module-Name: org.eclipse.pde.core
dc388e
diff --git a/eclipse.pde.ui/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/P2Utils.java b/eclipse.pde.ui/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/P2Utils.java
dc388e
index 696d2318f..7ab4596d5 100644
dc388e
--- a/eclipse.pde.ui/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/P2Utils.java
dc388e
+++ b/eclipse.pde.ui/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/P2Utils.java
dc388e
@@ -17,8 +17,9 @@ package org.eclipse.pde.internal.core;
dc388e
 import java.io.File;
dc388e
 import java.io.FileNotFoundException;
dc388e
 import java.io.IOException;
dc388e
-import java.net.MalformedURLException;
dc388e
-import java.net.URL;
dc388e
+import java.net.*;
dc388e
+import java.nio.file.Paths;
dc388e
+import java.util.Arrays;
dc388e
 import java.util.ArrayList;
dc388e
 import java.util.Collection;
dc388e
 import java.util.HashMap;
dc388e
@@ -31,7 +32,9 @@ import org.eclipse.core.runtime.IStatus;
dc388e
 import org.eclipse.core.runtime.NullProgressMonitor;
dc388e
 import org.eclipse.core.runtime.Path;
dc388e
 import org.eclipse.core.runtime.Status;
dc388e
+import org.eclipse.core.runtime.URIUtil;
dc388e
 import org.eclipse.equinox.frameworkadmin.BundleInfo;
dc388e
+import org.eclipse.equinox.internal.simpleconfigurator.utils.SimpleConfiguratorUtils;
dc388e
 import org.eclipse.equinox.p2.core.IProvisioningAgent;
dc388e
 import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
dc388e
 import org.eclipse.equinox.p2.engine.IEngine;
dc388e
@@ -60,6 +63,7 @@ import org.eclipse.pde.core.plugin.IPluginModelBase;
dc388e
 import org.eclipse.pde.core.plugin.TargetPlatform;
dc388e
 import org.eclipse.pde.internal.build.BundleHelper;
dc388e
 import org.eclipse.pde.internal.core.plugin.PluginBase;
dc388e
+import org.eclipse.pde.internal.core.util.ManifestUtils;
dc388e
 import org.osgi.framework.Constants;
dc388e
 
dc388e
 /**
dc388e
@@ -139,7 +143,16 @@ public class P2Utils {
dc388e
 		try {
dc388e
 			URL bundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), new File(configurationArea.getFile(), SimpleConfiguratorManipulator.BUNDLES_INFO_PATH).getAbsolutePath());
dc388e
 			File home = basePath.toFile();
dc388e
-			BundleInfo bundles[] = getBundlesFromFile(bundlesTxt, home);
dc388e
+			List<org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo> ibundleList = SimpleConfiguratorUtils.readConfiguration(bundlesTxt, home.toURI());
dc388e
+			List<BundleInfo> bundleList = new ArrayList<>();
dc388e
+			for (org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo b : ibundleList) {
dc388e
+				URI location = b.getLocation();
dc388e
+				if (!location.isAbsolute() && b.getBaseLocation() != null)
dc388e
+					location = URIUtil.makeAbsolute(location, b.getBaseLocation());
dc388e
+				BundleInfo binfo = new BundleInfo(b.getSymbolicName(), b.getVersion(), location, b.getStartLevel(), b.isMarkedAsStarted());
dc388e
+				bundleList.add(binfo);
dc388e
+			}
dc388e
+			BundleInfo[] bundles = bundleList.toArray(new BundleInfo[0]);
dc388e
 			if (bundles == null || bundles.length == 0) {
dc388e
 				return null;
dc388e
 			}
dc388e
@@ -168,11 +181,38 @@ public class P2Utils {
dc388e
 		try {
dc388e
 			File home = basePath.toFile();
dc388e
 			URL srcBundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), configurationArea.getFile().concat(SimpleConfiguratorManipulator.SOURCE_INFO_PATH));
dc388e
+			final List<BundleInfo> allSrcBundles = new ArrayList<>();
dc388e
+			try {
dc388e
+				for (File infoFile : SimpleConfiguratorUtils.getInfoFiles()) {
dc388e
+					File pluginsDir = Paths.get(infoFile.getParent(), "plugins").toFile(); //$NON-NLS-1$
dc388e
+					File[] sourceJars = pluginsDir.listFiles((dir, name) -> {
dc388e
+						return name.matches(".*\\.source_.*\\.jar$"); //$NON-NLS-1$
dc388e
+					});
dc388e
+					for (File sourceJar : sourceJars) {
dc388e
+						Map<String, String> manifest;
dc388e
+						try {
dc388e
+							manifest = ManifestUtils.loadManifest(sourceJar);
dc388e
+							final String bsn = manifest.get(Constants.BUNDLE_SYMBOLICNAME);
dc388e
+							final String version = manifest.get(Constants.BUNDLE_VERSION);
dc388e
+							BundleInfo info = new BundleInfo(bsn, version, sourceJar.toURI(), -1, false);
dc388e
+							allSrcBundles.add(info);
dc388e
+						} catch (CoreException e) {
dc388e
+							// continue
dc388e
+						}
dc388e
+					}
dc388e
+				}
dc388e
+			} catch (URISyntaxException e) {
dc388e
+				// continue
dc388e
+			}
dc388e
+
dc388e
 			BundleInfo srcBundles[] = getBundlesFromFile(srcBundlesTxt, home);
dc388e
-			if (srcBundles == null || srcBundles.length == 0) {
dc388e
+			if (srcBundles != null && srcBundles.length > 0) {
dc388e
+				allSrcBundles.addAll(Arrays.asList(srcBundles));
dc388e
+			}
dc388e
+			if (allSrcBundles.size() == 0) {
dc388e
 				return null;
dc388e
 			}
dc388e
-			return srcBundles;
dc388e
+			return allSrcBundles.toArray(new BundleInfo[0]);
dc388e
 		} catch (IOException e) {
dc388e
 			PDECore.log(e);
dc388e
 			return null;
dc388e
-- 
dc388e
2.21.1
dc388e