Skip to content

Commit

Permalink
Remove use of code deprecated and removed in Eclipse 2020-09
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-gallagher committed Sep 17, 2020
1 parent 480bb12 commit 1e958a5
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ Licensed under Apache License 2.0
Copyright 2001-2014 The Apache Software Foundation
Available from https://commons.apache.org/

Eclipse PDE pre-2020-09
Licensed under the Eclipse Public License v2.0
Available from https://git.eclipse.org/c/pde/eclipse.pde.ui.git/tree/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginPathFinder.java?id=11a09692b07fd57ba1e9e85f225edff215eb5a0f
9 changes: 5 additions & 4 deletions eclipse/bundles/org.openntf.xsp.sdk/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: OpenNTF
Import-Package: org.apache.commons.lang,
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.core.variables,
org.eclipse.debug.core,
org.eclipse.debug.internal.core,
Expand All @@ -33,16 +34,16 @@ Import-Package: org.apache.commons.lang,
org.eclipse.jdt.internal.ui.wizards,
org.eclipse.jdt.launching,
org.eclipse.jdt.ui.wizards,
org.eclipse.jface,
org.eclipse.jface.preference,
org.eclipse.jface.text,
org.eclipse.pde.launching,
org.eclipse.swt,
org.eclipse.ui,
org.eclipse.ui.actions,
org.eclipse.ui.forms,
org.eclipse.ui.forms.widgets,
org.eclipse.ui,
org.eclipse.ui.plugin,
org.eclipse.jface,
org.eclipse.pde.launching,
org.eclipse.core.runtime
org.eclipse.update.configurator


Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
Expand All @@ -51,10 +55,10 @@
import org.eclipse.ui.PlatformUI;
import org.openntf.xsp.sdk.Activator;
import org.openntf.xsp.sdk.commons.osgi.LaunchUtil;
import org.openntf.xsp.sdk.exceptions.AbortException;
import org.openntf.xsp.sdk.commons.platform.INotesDominoPlatform;
import org.openntf.xsp.sdk.commons.utils.CommonUtils;
import org.openntf.xsp.sdk.commons.utils.StringUtil;
import org.openntf.xsp.sdk.exceptions.AbortException;

/**
* @author dtaieb
Expand Down Expand Up @@ -141,7 +145,7 @@ private void doLaunch(ILaunchConfiguration configuration, String mode, ILaunch l

// Call preLaunchCheck to fill the bundleMap
try {
preLaunchCheck(configuration, launch, new SubProgressMonitor(monitor, 2));
preLaunchCheck(configuration, launch, SubMonitor.convert(monitor, 2));
} catch (CoreException e) {
if (e.getStatus().getSeverity() == IStatus.CANCEL) {
monitor.setCanceled(true);
Expand Down Expand Up @@ -326,7 +330,7 @@ private String getBundleUrl(IPluginModelBase model, boolean bIncludeReference) {
private Map<String, IPluginModelBase> computeTargetModels(Map<?, ?> workspacePlugins, String eclipseLocation) {
Map<String, IPluginModelBase> modelMap = new HashMap<String, IPluginModelBase>();

URL[] pluginPaths = PluginPathFinder.getPluginPaths(eclipseLocation, false);
URL[] pluginPaths = PluginPathFinder.scanLocations(getSites(eclipseLocation, false));
PDEState pdeState;
// The signature for PDEState's constructor changed in Eclipse 2019-03
// https://github.com/eclipse/eclipse.pde.ui/commit/3db2f1e50aa7ae5efc0e07a1f26eecedd80a7159#diff-a56311895a435ece21aa9ef829607884
Expand Down Expand Up @@ -401,4 +405,89 @@ private Collection<String> computeOsgiBundles(INotesDominoPlatform ndPlatform, S
public abstract String[] getProfiles();
public abstract String getName();

// *******************************************************************************
// * Code from older PluginPathFinder build for patched compatibility
// *******************************************************************************

/**
*
* @param platformHome
* @param features false for plugin sites, true for feature sites
* @return array of ".../plugins" or ".../features" Files
*/
private static File[] getSites(String platformHome, boolean features) {
HashSet<File> sites = new HashSet<>();
File file = new File(platformHome, features ? "features" : "plugins"); //$NON-NLS-1$ //$NON-NLS-2$
if (!features && !file.exists()) {
file = new File(platformHome);
}
if (file.exists()) {
sites.add(file);
}

File[] linkFiles = new File(platformHome + IPath.SEPARATOR + "links").listFiles(); //$NON-NLS-1$
if (linkFiles != null) {
for (File linkFile : linkFiles) {
String path = getSitePath(platformHome, linkFile, features);
if (path != null) {
sites.add(new File(path));
}
}
}

// If there is no features/plugins folder and no linked files, try the home location
if (sites.isEmpty()) {
file = new File(platformHome);
if (file.exists()) {
sites.add(file);
}
}

return sites.toArray(new File[sites.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;
}

/**
*
* @param platformHome
* @param linkFile
* @param features false for plugins, true for features
* @return path of plugins or features directory of an extension site
*/
private static String getSitePath(String platformHome, File linkFile, boolean features) {
String prefix = new Path(platformHome).removeLastSegments(1).toString();
Properties properties = new Properties();
try (FileInputStream fis = new FileInputStream(linkFile)) {
properties.load(fis);
String path = properties.getProperty("path"); //$NON-NLS-1$
if (path != null) {
if (!new Path(path).isAbsolute()) {
path = prefix + IPath.SEPARATOR + path;
}
path += IPath.SEPARATOR + "eclipse" + IPath.SEPARATOR; //$NON-NLS-1$
if (features) {
path += "features"; //$NON-NLS-1$
} else {
path += "plugins"; //$NON-NLS-1$
}
if (new File(path).exists()) {
return path;
}
}
} catch (IOException e) {
}
return null;
}
}

0 comments on commit 1e958a5

Please sign in to comment.