Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 235336 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/TargetWeaver.java (-39 lines)
Lines 15-24 Link Here
15
import java.net.URL;
15
import java.net.URL;
16
import java.util.*;
16
import java.util.*;
17
import java.util.Map.Entry;
17
import java.util.Map.Entry;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.pde.core.plugin.IPluginModelBase;
19
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
import org.eclipse.pde.core.plugin.TargetPlatform;
22
import org.osgi.framework.Constants;
20
import org.osgi.framework.Constants;
23
21
24
/**
22
/**
Lines 40-50 Link Here
40
	private static String fgDevPropertiesURL = null;
38
	private static String fgDevPropertiesURL = null;
41
39
42
	/**
40
	/**
43
	 * Location of configuration area
44
	 */
45
	private static String fgConfigAreaURL = null;
46
47
	/**
48
	 * Property file corresponding to dev.properties
41
	 * Property file corresponding to dev.properties
49
	 */
42
	 */
50
	private static Properties fgDevProperties = null;
43
	private static Properties fgDevProperties = null;
Lines 56-94 Link Here
56
		fgIsDev = Platform.inDevelopmentMode();
49
		fgIsDev = Platform.inDevelopmentMode();
57
		if (fgIsDev) {
50
		if (fgIsDev) {
58
			fgDevPropertiesURL = System.getProperty("osgi.dev"); //$NON-NLS-1$
51
			fgDevPropertiesURL = System.getProperty("osgi.dev"); //$NON-NLS-1$
59
			fgConfigAreaURL = System.getProperty("osgi.configuration.area"); //$NON-NLS-1$
60
		}
61
	}
62
63
	/**
64
	 * Returns the configuration area for the platform as a directory. The default
65
	 * location is the 'configuration' directory in the home location but can be
66
	 * overridden with the -configuration command line argument.
67
	 * 
68
	 * @param platformHome absolute path in the local file system to an installation
69
	 * @return configuration area
70
	 */
71
	public static File getConfigurationArea(String platformHome) {
72
		// only weave in development mode
73
		if (fgIsDev && fgConfigAreaURL != null) {
74
			if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation()))) {
75
				// only point to dev config area for default target platform
76
				try {
77
					URL url = new URL(fgConfigAreaURL);
78
					String file = url.getFile();
79
					if (file != null && file.length() > 0) {
80
						File area = new File(file);
81
						if (area != null && area.exists()) {
82
							return area;
83
						}
84
					}
85
				} catch (MalformedURLException e) {
86
					PDECore.log(e);
87
				}
88
			}
89
		}
52
		}
90
		// default
91
		return new File(platformHome, "configuration"); //$NON-NLS-1$
92
	}
53
	}
93
54
94
	/**
55
	/**
(-)src/org/eclipse/pde/internal/core/P2Utils.java (-30 / +29 lines)
Lines 37-72 Link Here
37
	/**
37
	/**
38
	 * Returns bundles defined by the 'bundles.info' file in the
38
	 * Returns bundles defined by the 'bundles.info' file in the
39
	 * specified location, or <code>null</code> if none. The "bundles.info" file
39
	 * specified location, or <code>null</code> if none. The "bundles.info" file
40
	 * is assumed to be at a fixed relative location to the specified file.  This 
40
	 * is assumed to be at a fixed location relative to the configuration area URL.
41
	 * method will also look for a "source.info".  If available, any source
41
	 * This method will also look for a "source.info".  If available, any source
42
	 * bundles found will also be added to the returned list.
42
	 * bundles found will also be added to the returned list.  If bundle URLs found
43
	 * in the bundles.txt are relative, they will be appended to platformHome to
44
	 * make them absolute.
43
	 * 
45
	 * 
44
	 * @param platformHome absolute path in the local file system to an installation
46
	 * @param platformHome absolute path in the local file system to an installation
47
	 * @param configurationArea url location of the configuration directory to search for bundles.info and source.info
45
	 * @return URLs of all bundles in the installation or <code>null</code> if not able
48
	 * @return URLs of all bundles in the installation or <code>null</code> if not able
46
	 * 	to locate a bundles.info
49
	 * 	to locate a bundles.info
47
	 */
50
	 */
48
	public static URL[] readBundlesTxt(String platformHome) {
51
	public static URL[] readBundlesTxt(String platformHome, URL configurationArea) {
49
50
		Path basePath = new Path(platformHome);
52
		Path basePath = new Path(platformHome);
51
53
		if (configurationArea == null) {
52
		File configArea = TargetWeaver.getConfigurationArea(platformHome);
53
		File bundlesTxt = new File(configArea, BUNDLE_TXT_PATH);
54
		List bundles = getBundlesFromFile(bundlesTxt, basePath);
55
56
		if (bundles == null) {
57
			return null;
54
			return null;
58
		}
55
		}
56
		try {
57
			URL bundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), configurationArea.getFile().concat(BUNDLE_TXT_PATH));
58
			List bundles = getBundlesFromFile(bundlesTxt, basePath);
59
60
			if (bundles == null) {
61
				return null;
62
			}
59
63
60
		File srcBundlesTxt = new File(configArea, SRC_BUNDLE_TXT_PATH);
64
			URL srcBundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), configurationArea.getFile().concat(SRC_BUNDLE_TXT_PATH));
61
		List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath);
65
			List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath);
62
66
63
		if (srcBundles == null) {
67
			if (srcBundles != null) {
68
				bundles.addAll(srcBundles);
69
			}
64
			return (URL[]) bundles.toArray(new URL[bundles.size()]);
70
			return (URL[]) bundles.toArray(new URL[bundles.size()]);
65
		}
66
67
		bundles.addAll(srcBundles);
68
		return (URL[]) bundles.toArray(new URL[bundles.size()]);
69
71
72
		} catch (MalformedURLException e) {
73
			PDECore.log(e);
74
			return null;
75
		}
70
	}
76
	}
71
77
72
	/**
78
	/**
Lines 75-97 Link Here
75
	 * Returns a list of URL locations, one for each bundle entry or <code>
81
	 * Returns a list of URL locations, one for each bundle entry or <code>
76
	 * null</code> if there is a problem reading the file.
82
	 * null</code> if there is a problem reading the file.
77
	 * 
83
	 * 
78
	 * @param file the file to read
84
	 * @param file the URL of the file to read
79
	 * @param basePath the path describing the base location of the platform install
85
	 * @param basePath the path describing the base location of the platform install
80
	 * @return list containing URL locations or <code>null</code>
86
	 * @return list containing URL locations or <code>null</code>
81
	 */
87
	 */
82
	private static List getBundlesFromFile(File file, Path basePath) {
88
	private static List getBundlesFromFile(URL fileURL, Path basePath) {
83
		if (!file.exists()) {
84
			return null;
85
		}
86
		URL url = null;
87
		try {
88
			url = file.toURL();
89
		} catch (MalformedURLException e) {
90
			return null;
91
		}
92
		List bundles = new ArrayList();
89
		List bundles = new ArrayList();
93
		try {
90
		try {
94
			BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
91
			BufferedReader r = new BufferedReader(new InputStreamReader(fileURL.openStream()));
95
92
96
			String line;
93
			String line;
97
			try {
94
			try {
Lines 156-163 Link Here
156
				}
153
				}
157
			}
154
			}
158
		} catch (MalformedURLException e) {
155
		} catch (MalformedURLException e) {
156
			PDECore.log(e);
159
			return null;
157
			return null;
160
		} catch (IOException e) {
158
		} catch (IOException e) {
159
			PDECore.log(e);
161
			return null;
160
			return null;
162
		}
161
		}
163
		return bundles;
162
		return bundles;
(-)src/org/eclipse/pde/internal/core/PluginPathFinder.java (-1 / +22 lines)
Lines 17-22 Link Here
17
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.core.variables.IStringVariableManager;
18
import org.eclipse.core.variables.IStringVariableManager;
19
import org.eclipse.core.variables.VariablesPlugin;
19
import org.eclipse.core.variables.VariablesPlugin;
20
import org.eclipse.osgi.service.datalocation.Location;
20
import org.eclipse.pde.core.plugin.TargetPlatform;
21
import org.eclipse.pde.core.plugin.TargetPlatform;
21
import org.eclipse.update.configurator.ConfiguratorUtils;
22
import org.eclipse.update.configurator.ConfiguratorUtils;
22
import org.eclipse.update.configurator.IPlatformConfiguration;
23
import org.eclipse.update.configurator.IPlatformConfiguration;
Lines 85-98 Link Here
85
	}
86
	}
86
87
87
	public static URL[] getPluginPaths(String platformHome) {
88
	public static URL[] getPluginPaths(String platformHome) {
89
		// If we don't care about installed bundles, simply scan the location
88
		Preferences store = PDECore.getDefault().getPluginPreferences();
90
		Preferences store = PDECore.getDefault().getPluginPreferences();
89
		if (!store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION))
91
		if (!store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION))
90
			return scanLocations(getSites(platformHome, false));
92
			return scanLocations(getSites(platformHome, false));
91
93
92
		URL[] urls = P2Utils.readBundlesTxt(platformHome);
94
		// See if we can find a bundles.info to get installed bundles from
95
		URL[] urls = null;
96
		if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation()))) {
97
			// Pointing at default install, so use the actual configuration area
98
			Location configArea = Platform.getConfigurationLocation();
99
			if (configArea != null) {
100
				urls = P2Utils.readBundlesTxt(platformHome, configArea.getURL());
101
			}
102
		} else {
103
			// Pointing at a folder, so try to guess the configuration area
104
			File configurationArea = new File(platformHome, "configuration"); //$NON-NLS-1$
105
			if (configurationArea.exists()) {
106
				try {
107
					urls = P2Utils.readBundlesTxt(platformHome, configurationArea.toURL());
108
				} catch (MalformedURLException e) {
109
					PDECore.log(e);
110
				}
111
			}
112
		}
93
		if (urls != null) {
113
		if (urls != null) {
94
			return urls;
114
			return urls;
95
		}
115
		}
116
96
		if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation())) && !isDevLaunchMode())
117
		if (new Path(platformHome).equals(new Path(TargetPlatform.getDefaultLocation())) && !isDevLaunchMode())
97
			return ConfiguratorUtils.getCurrentPlatformConfiguration().getPluginPath();
118
			return ConfiguratorUtils.getCurrentPlatformConfiguration().getPluginPath();
98
119

Return to bug 235336