Search in sources :

Example 1 with EEType

use of org.eclipse.tycho.core.ee.EEVersion.EEType in project tycho by eclipse.

the class StandardExecutionEnvironment method parseEEVersion.

private EEVersion parseEEVersion(String systemCaps) {
    List<EEVersion> eeVersions = new ArrayList<>();
    try {
        ManifestElement[] systemCapValues = ManifestElement.parseHeader("org.osgi.framework.system.capabilities", systemCaps);
        for (int i = 0; i < systemCapValues.length; i++) {
            Version version;
            String singleVersion = systemCapValues[i].getAttribute("version:Version");
            if (singleVersion != null) {
                version = Version.parseVersion(singleVersion);
            } else {
                String[] versions = systemCapValues[i].getAttribute("version:List<Version>").split(",");
                List<Version> osgiVersions = new ArrayList<>(versions.length);
                for (String currentVersion : versions) {
                    osgiVersions.add(Version.parseVersion(currentVersion));
                }
                version = Collections.max(osgiVersions);
            }
            String execEnv = systemCapValues[i].getAttribute("osgi.ee");
            EEType eeType = EEType.fromName(execEnv);
            if (eeType != null) {
                eeVersions.add(new EEVersion(version, eeType));
            }
        }
        return Collections.max(eeVersions);
    } catch (BundleException e) {
        throw new RuntimeException(e);
    }
}
Also used : ManifestElement(org.eclipse.osgi.util.ManifestElement) ArrayList(java.util.ArrayList) EEType(org.eclipse.tycho.core.ee.EEVersion.EEType) Version(org.osgi.framework.Version) BundleException(org.osgi.framework.BundleException)

Aggregations

ArrayList (java.util.ArrayList)1 ManifestElement (org.eclipse.osgi.util.ManifestElement)1 EEType (org.eclipse.tycho.core.ee.EEVersion.EEType)1 BundleException (org.osgi.framework.BundleException)1 Version (org.osgi.framework.Version)1