|
14 | 14 | import static java.lang.String.format;
|
15 | 15 | import static java.util.Arrays.stream;
|
16 | 16 | import static java.util.Collections.emptyList;
|
| 17 | +import static java.util.function.Predicate.not; |
17 | 18 | import static org.eclipse.core.runtime.IProgressMonitor.done;
|
18 | 19 | import static org.eclipse.rcptt.internal.launching.ext.Q7ExtLaunchingPlugin.PLUGIN_ID;
|
19 | 20 |
|
|
110 | 111 | import org.osgi.framework.BundleException;
|
111 | 112 | import org.osgi.framework.Version;
|
112 | 113 |
|
| 114 | +import com.google.common.base.Joiner; |
113 | 115 | import com.google.common.base.Objects;
|
114 | 116 | import com.google.common.base.Preconditions;
|
115 | 117 | import com.google.common.collect.HashMultimap;
|
@@ -517,6 +519,7 @@ public IStatus resolve(IProgressMonitor monitor) {
|
517 | 519 |
|
518 | 520 | private void index() {
|
519 | 521 | stream(target.getBundles()).forEach(bundle -> targetBundleIndex.put(bundle.getBundleInfo().getSymbolicName(), bundle));
|
| 522 | + targetBundleIndex.removeAll(null); |
520 | 523 | }
|
521 | 524 |
|
522 | 525 | private void resetIndex() {
|
@@ -1059,38 +1062,40 @@ public String getTemplateConfigLocation() {
|
1059 | 1062 | public OSArchitecture detectArchitecture(
|
1060 | 1063 | boolean preferCurrentVmArchitecture, StringBuilder detectMsg) {
|
1061 | 1064 | checkResolved();
|
| 1065 | + String architecture = target.getArch(); |
| 1066 | + if (architecture != null) { |
| 1067 | + return OSArchitecture.valueOf(architecture); |
| 1068 | + } |
| 1069 | + |
1062 | 1070 | String os = Platform.getOS();
|
1063 |
| - TargetBundle[] bundles = target.getAllBundles(); |
1064 |
| - for (TargetBundle b : bundles) { |
1065 |
| - BundleInfo info = b.getBundleInfo(); |
1066 |
| - String name = info.getSymbolicName(); |
1067 |
| - if (name != null && name.startsWith("org.eclipse.equinox.launcher")) { |
1068 |
| - if (!name.contains(os)) { |
1069 |
| - continue; |
1070 |
| - } |
1071 |
| - URI location = info.getLocation(); |
1072 |
| - if (location == null || location.getPath() == null) { |
1073 |
| - continue; |
1074 |
| - } |
1075 |
| - |
1076 |
| - if (name.contains("aarch64")) { |
1077 |
| - if (detectMsg != null) { |
1078 |
| - detectMsg.append("aarch64 arch is selected because AUT uses " + name); |
1079 |
| - } |
1080 |
| - return OSArchitecture.aarch64; |
1081 |
| - } else if (name.contains("x86_64")) { |
1082 |
| - if (detectMsg != null) { |
1083 |
| - detectMsg.append("x86_64 arch is selected because AUT uses " + name); |
1084 |
| - } |
1085 |
| - return OSArchitecture.x86_64; |
1086 |
| - } else if (name.contains("x86")) { |
1087 |
| - if (detectMsg != null) { |
1088 |
| - detectMsg.append("x86 arch is selected because AUT uses " + name); |
1089 |
| - } |
1090 |
| - return OSArchitecture.x86; |
1091 |
| - |
1092 |
| - } |
| 1071 | + Set<String> launcherLibraries = targetBundleIndex.keySet().stream().filter(name -> name.startsWith("org.eclipse.equinox.launcher") && name.contains(os)).collect(Collectors.toSet()); |
| 1072 | + if (launcherLibraries.size() != 1) { |
| 1073 | + if (detectMsg != null) { |
| 1074 | + detectMsg.append("Multiple launcher libraries are found in target platform: " + Joiner.on(", ").join(launcherLibraries)); |
1093 | 1075 | }
|
| 1076 | + return OSArchitecture.Unknown; |
| 1077 | + } |
| 1078 | + |
| 1079 | + String name = launcherLibraries.iterator().next(); |
| 1080 | + if (name.contains("aarch64")) { |
| 1081 | + if (detectMsg != null) { |
| 1082 | + detectMsg.append("aarch64 arch is selected because AUT uses " + name); |
| 1083 | + } |
| 1084 | + return OSArchitecture.aarch64; |
| 1085 | + } else if (name.contains("x86_64")) { |
| 1086 | + if (detectMsg != null) { |
| 1087 | + detectMsg.append("x86_64 arch is selected because AUT uses " + name); |
| 1088 | + } |
| 1089 | + return OSArchitecture.x86_64; |
| 1090 | + } else if (name.contains("x86")) { |
| 1091 | + if (detectMsg != null) { |
| 1092 | + detectMsg.append("x86 arch is selected because AUT uses " + name); |
| 1093 | + } |
| 1094 | + return OSArchitecture.x86; |
| 1095 | + } |
| 1096 | + |
| 1097 | + if (detectMsg != null) { |
| 1098 | + detectMsg.append("Unrecognized launcher architecture: " + name); |
1094 | 1099 | }
|
1095 | 1100 |
|
1096 | 1101 | return OSArchitecture.Unknown;
|
@@ -1239,8 +1244,7 @@ public String toString() {
|
1239 | 1244 |
|
1240 | 1245 | @Override
|
1241 | 1246 | public Map<String, org.eclipse.equinox.p2.metadata.Version> getVersions() throws CoreException {
|
1242 |
| - if (!getStatus().isOK()) |
1243 |
| - throw new CoreException(getStatus()); |
| 1247 | + checkResolved(); |
1244 | 1248 | return AUTInformation.getInformationMap(target);
|
1245 | 1249 | }
|
1246 | 1250 |
|
@@ -1706,30 +1710,33 @@ private static void debug(String message) {
|
1706 | 1710 | }
|
1707 | 1711 | private void setStartLevels(SubMonitor monitor) throws IOException, BundleException {
|
1708 | 1712 | Map<String, BundleStart> levelMap = getRunlevelsMap();
|
1709 |
| - |
1710 |
| - if (levelMap.isEmpty()) { |
1711 |
| - warning("No start levels are configured"); |
1712 |
| - } |
1713 | 1713 | if (!target.isResolved()) {
|
1714 | 1714 | throw new IllegalStateException("Target definition is unresolved");
|
1715 | 1715 | }
|
1716 |
| - |
| 1716 | + |
1717 | 1717 | TargetBundle[] bundles = target.getBundles();
|
1718 | 1718 | monitor.beginTask("Setting bundle start levels", bundles.length);
|
1719 | 1719 | for (TargetBundle bundle : bundles) {
|
1720 |
| - monitor.subTask(bundle.getBundleInfo().getLocation().toString()); |
1721 |
| - BundleStart bundleLevel = levelMap.getOrDefault(bundle.getBundleInfo().getSymbolicName(), BundleStart.DEFAULT); |
1722 |
| - bundleLevel = StartLevelSupport.getStartInfo(bundle.getBundleInfo().getManifest(), bundleLevel); |
| 1720 | + BundleInfo bundleInfo = bundle.getBundleInfo(); |
| 1721 | + monitor.subTask(bundleInfo.getLocation().toString()); |
| 1722 | + BundleStart bundleLevel = levelMap.getOrDefault(bundleInfo.getSymbolicName(), BundleStart.DEFAULT); |
| 1723 | + bundleLevel = StartLevelSupport.getStartInfo(bundleInfo.getManifest(), bundleLevel); |
1723 | 1724 | monitor.split(1);
|
1724 |
| - if (bundleLevel != null) { |
1725 |
| - try { |
1726 |
| - bundle.getBundleInfo().setStartLevel(bundleLevel.level); |
1727 |
| - bundle.getBundleInfo().setMarkedAsStarted(bundleLevel.autoStart); |
1728 |
| - } catch (RuntimeException e) { |
1729 |
| - throw new IllegalStateException(format("Invalid run level descriptor for bundle %s : %s ", bundle.getBundleInfo().getSymbolicName(), bundleLevel), e); |
1730 |
| - } |
| 1725 | + if (bundleLevel.isDefault()) { |
| 1726 | + continue; |
| 1727 | + } |
| 1728 | + try { |
| 1729 | + bundleInfo.setStartLevel(bundleLevel.level); |
| 1730 | + bundleInfo.setMarkedAsStarted(bundleLevel.autoStart); |
| 1731 | + } catch (RuntimeException e) { |
| 1732 | + throw new IllegalStateException(format("Invalid run level descriptor for bundle %s : %s ", bundleInfo.getSymbolicName(), bundleLevel), e); |
1731 | 1733 | }
|
1732 | 1734 | }
|
| 1735 | + if (!stream(bundles).map(TargetBundle::getBundleInfo).map(BundleStart::fromBundle).anyMatch(not(BundleStart::isDefault))) { |
| 1736 | + // this happens only if target platform has no bundles from org.eclipse.rcptt.launching.ext.StartLevelSupport.predefined |
| 1737 | + warning("No start levels are configured"); |
| 1738 | + } |
| 1739 | + |
1733 | 1740 | }
|
1734 | 1741 |
|
1735 | 1742 | private void warning(String message) {
|
|
0 commit comments