|
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; |