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/P2Utils.java (-25 / +29 lines)
Lines 15-20 Link Here
15
import java.net.URL;
15
import java.net.URL;
16
import java.util.*;
16
import java.util.*;
17
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.*;
18
import org.eclipse.osgi.service.datalocation.Location;
18
import org.eclipse.osgi.service.resolver.BundleDescription;
19
import org.eclipse.osgi.service.resolver.BundleDescription;
19
import org.eclipse.pde.core.plugin.IPluginBase;
20
import org.eclipse.pde.core.plugin.IPluginBase;
20
import org.eclipse.pde.core.plugin.IPluginModelBase;
21
import org.eclipse.pde.core.plugin.IPluginModelBase;
Lines 46-72 Link Here
46
	 * 	to locate a bundles.info
47
	 * 	to locate a bundles.info
47
	 */
48
	 */
48
	public static URL[] readBundlesTxt(String platformHome) {
49
	public static URL[] readBundlesTxt(String platformHome) {
49
50
		Path basePath = new Path(platformHome);
50
		Path basePath = new Path(platformHome);
51
51
52
		File configArea = TargetWeaver.getConfigurationArea(platformHome);
52
		Location configLocation = Platform.getConfigurationLocation();
53
		File bundlesTxt = new File(configArea, BUNDLE_TXT_PATH);
53
		if (configLocation == null) {
54
		List bundles = getBundlesFromFile(bundlesTxt, basePath);
54
			return null;
55
55
		}
56
		if (bundles == null) {
56
		URL configURL = configLocation.getURL();
57
		if (configURL == null) {
57
			return null;
58
			return null;
58
		}
59
		}
59
60
60
		File srcBundlesTxt = new File(configArea, SRC_BUNDLE_TXT_PATH);
61
		try {
61
		List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath);
62
			URL bundlesTxt = new URL(configURL.getProtocol(), configURL.getHost(), configURL.getFile().concat(BUNDLE_TXT_PATH));
63
			List bundles = getBundlesFromFile(bundlesTxt, basePath);
62
64
63
		if (srcBundles == null) {
65
			if (bundles == null) {
64
			return (URL[]) bundles.toArray(new URL[bundles.size()]);
66
				return null;
65
		}
67
			}
66
68
67
		bundles.addAll(srcBundles);
69
			URL srcBundlesTxt = new URL(configURL.getProtocol(), configURL.getHost(), configURL.getFile().concat(SRC_BUNDLE_TXT_PATH));
68
		return (URL[]) bundles.toArray(new URL[bundles.size()]);
70
			List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath);
69
71
72
			if (srcBundles != null) {
73
				bundles.addAll(srcBundles);
74
			}
75
			return (URL[]) bundles.toArray(new URL[bundles.size()]);
76
77
		} catch (MalformedURLException e) {
78
			PDECore.log(e);
79
			return null;
80
		}
70
	}
81
	}
71
82
72
	/**
83
	/**
Lines 75-97 Link Here
75
	 * Returns a list of URL locations, one for each bundle entry or <code>
86
	 * Returns a list of URL locations, one for each bundle entry or <code>
76
	 * null</code> if there is a problem reading the file.
87
	 * null</code> if there is a problem reading the file.
77
	 * 
88
	 * 
78
	 * @param file the file to read
89
	 * @param file the URL of the file to read
79
	 * @param basePath the path describing the base location of the platform install
90
	 * @param basePath the path describing the base location of the platform install
80
	 * @return list containing URL locations or <code>null</code>
91
	 * @return list containing URL locations or <code>null</code>
81
	 */
92
	 */
82
	private static List getBundlesFromFile(File file, Path basePath) {
93
	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();
94
		List bundles = new ArrayList();
93
		try {
95
		try {
94
			BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream()));
96
			BufferedReader r = new BufferedReader(new InputStreamReader(fileURL.openStream()));
95
97
96
			String line;
98
			String line;
97
			try {
99
			try {
Lines 156-163 Link Here
156
				}
158
				}
157
			}
159
			}
158
		} catch (MalformedURLException e) {
160
		} catch (MalformedURLException e) {
161
			PDECore.log(e);
159
			return null;
162
			return null;
160
		} catch (IOException e) {
163
		} catch (IOException e) {
164
			PDECore.log(e);
161
			return null;
165
			return null;
162
		}
166
		}
163
		return bundles;
167
		return bundles;
(-)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
	/**

Return to bug 235336