Search in sources :

Example 6 with SystemCapability

use of org.eclipse.tycho.core.ee.shared.SystemCapability in project tycho by eclipse.

the class CustomExecutionEnvironmentTest method testJavaSEVersionNameMappings.

@Test
public void testJavaSEVersionNameMappings() throws Exception {
    List<SystemCapability> javaSeVersions = new ArrayList<>();
    for (String version : new String[] { "1.2.0", "1.3.0", "1.4.0", "1.5.0", "1.6.0", "1.7.0" }) {
        SystemCapability capability = new SystemCapability(Type.OSGI_EE, "JavaSE", version);
        javaSeVersions.add(capability);
    }
    customExecutionEnvironment = new CustomExecutionEnvironment("name", javaSeVersions);
    assertThat(customExecutionEnvironment.getProfileProperties().size(), is(3));
    assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "J2SE-1.2,J2SE-1.3,J2SE-1.4,J2SE-1.5,JavaSE-1.6,JavaSE-1.7");
}
Also used : SystemCapability(org.eclipse.tycho.core.ee.shared.SystemCapability) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with SystemCapability

use of org.eclipse.tycho.core.ee.shared.SystemCapability in project tycho by eclipse.

the class DependencyComputerTest method testWiringToPackageFromCustomProfile.

// TODO code reuse
@Test
public void testWiringToPackageFromCustomProfile() throws Exception {
    File basedir = getBasedir("projects/customProfile");
    Map<File, MavenProject> basedirMap = MavenSessionUtils.getBasedirMap(getSortedProjects(basedir, null));
    MavenProject project = basedirMap.get(new File(basedir, "bundle"));
    DependencyArtifacts platform = (DependencyArtifacts) project.getContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS);
    CustomExecutionEnvironment customProfile = new CustomExecutionEnvironment("custom", Arrays.asList(// 
    new SystemCapability(Type.JAVA_PACKAGE, "package.historically.not.in.jdk", "1.2.1"), // 
    new SystemCapability(Type.OSGI_EE, "OSGi/Minimum", "1.0.0"), // 
    new SystemCapability(Type.OSGI_EE, "JavaSE", "1.0.0"), // 
    new SystemCapability(Type.OSGI_EE, "JavaSE", "1.1.0"), new SystemCapability(Type.OSGI_EE, "JavaSE", "1.2.0")));
    State state = resolver.newResolvedState(project, customProfile, false, platform);
    BundleDescription bundle = state.getBundleByLocation(project.getBasedir().getAbsolutePath());
    List<DependencyEntry> dependencies = dependencyComputer.computeDependencies(state.getStateHelper(), bundle);
    if (dependencies.size() > 0) {
        assertThat(dependencies.size(), is(1));
        assertThat(dependencies.get(0).desc.getSymbolicName(), is(Constants.SYSTEM_BUNDLE_SYMBOLICNAME));
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) MavenProject(org.apache.maven.project.MavenProject) SystemCapability(org.eclipse.tycho.core.ee.shared.SystemCapability) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) CustomExecutionEnvironment(org.eclipse.tycho.core.ee.CustomExecutionEnvironment) DependencyEntry(org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry) File(java.io.File) Test(org.junit.Test)

Example 8 with SystemCapability

use of org.eclipse.tycho.core.ee.shared.SystemCapability in project tycho by eclipse.

the class CustomEEResolutionHandler method readFullSpecification.

@Override
public void readFullSpecification(Collection<IInstallableUnit> targetPlatformContent) {
    IInstallableUnit specificationUnit = findSpecificationUnit(targetPlatformContent, getResolutionHints());
    List<SystemCapability> systemCapabilities = readCapabilities(specificationUnit);
    eeConfiguration.setFullSpecificationForCustomProfile(systemCapabilities);
}
Also used : SystemCapability(org.eclipse.tycho.core.ee.shared.SystemCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 9 with SystemCapability

use of org.eclipse.tycho.core.ee.shared.SystemCapability in project tycho by eclipse.

the class CustomExecutionEnvironment method setExecutionEnvironmentProperties.

private void setExecutionEnvironmentProperties(List<SystemCapability> systemCapabilities) {
    StringBuilder executionEnvironmentProperty = new StringBuilder();
    for (SystemCapability capability : systemCapabilities) {
        if (capability.getType() == Type.OSGI_EE) {
            String environmentName = capability.getName();
            String version = normalizeVersion(capability.getVersion());
            append(executionEnvironmentProperty, toExecutionEnvironment(environmentName, version));
        }
    }
    setPropertyIfNotEmpty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, executionEnvironmentProperty);
}
Also used : SystemCapability(org.eclipse.tycho.core.ee.shared.SystemCapability)

Example 10 with SystemCapability

use of org.eclipse.tycho.core.ee.shared.SystemCapability in project tycho by eclipse.

the class CustomExecutionEnvironment method setOsgiSystemCapabilities.

private void setOsgiSystemCapabilities(List<SystemCapability> systemCapabilities) {
    Map<String, MultipleVersionsCapability> capabilityMap = new LinkedHashMap<>();
    for (SystemCapability capability : systemCapabilities) {
        if (capability.getType() == Type.OSGI_EE) {
            String environmentName = capability.getName();
            String version = normalizeVersion(capability.getVersion());
            if (capabilityMap.containsKey(environmentName)) {
                capabilityMap.get(environmentName).addVersion(version);
            } else {
                capabilityMap.put(environmentName, new MultipleVersionsCapability(environmentName, version));
            }
        }
    }
    StringBuilder systemCapabilitesProperty = new StringBuilder();
    for (MultipleVersionsCapability capability : capabilityMap.values()) {
        append(systemCapabilitesProperty, capability.toString());
    }
    setPropertyIfNotEmpty(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilitesProperty);
}
Also used : SystemCapability(org.eclipse.tycho.core.ee.shared.SystemCapability) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SystemCapability (org.eclipse.tycho.core.ee.shared.SystemCapability)10 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 MavenProject (org.apache.maven.project.MavenProject)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)1 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)1 State (org.eclipse.osgi.service.resolver.State)1 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)1 CustomExecutionEnvironment (org.eclipse.tycho.core.ee.CustomExecutionEnvironment)1 DependencyEntry (org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry)1