summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHolger Oehm2012-10-11 03:21:47 (EDT)
committer Tobias Oberlies2012-10-12 10:05:13 (EDT)
commit1a71b3eb857f971f39a91582cd028f1a9adc4b50 (patch)
tree5f23b54ac63e3025cf8e7b9960530fa787bb6d7d
parent79e25d479bf96e80402888500be91c6c7276872d (diff)
downloadorg.eclipse.tycho-1a71b3eb857f971f39a91582cd028f1a9adc4b50.zip
org.eclipse.tycho-1a71b3eb857f971f39a91582cd028f1a9adc4b50.tar.gz
org.eclipse.tycho-1a71b3eb857f971f39a91582cd028f1a9adc4b50.tar.bz2
385930 Implement ExecutionEnvironment for custom profilesrefs/changes/69/8169/2
- Generate the profile properties for Equinox from the information available in the 'a.jre' IU. This in particular requires to regenerate the old BREE-style org.osgi.framework.executionenvironment property from the new osgi.ee capabilities. - Test that verifies that Equinox resolver takes the properties from such a custom profile into account. Bug: 385930 Change-Id: Ibd464b032bb8fe1964afaafaaba3f82def6ed33d
-rw-r--r--tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/ee/shared/SystemCapability.java41
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironment.java194
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java5
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironmentTest.java158
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java41
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/alternativeProvider/META-INF/MANIFEST.MF7
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/alternativeProvider/build.properties4
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/alternativeProvider/pom.xml15
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/bundle/META-INF/MANIFEST.MF7
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/bundle/build.properties4
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/bundle/pom.xml15
-rw-r--r--tycho-core/src/test/resources/projects/customProfile/pom.xml16
12 files changed, 506 insertions, 1 deletions
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/ee/shared/SystemCapability.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/ee/shared/SystemCapability.java
new file mode 100644
index 0000000..993ce2c
--- /dev/null
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/ee/shared/SystemCapability.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.core.ee.shared;
+
+public class SystemCapability {
+
+ public enum Type {
+ JAVA_PACKAGE, OSGI_EE
+ }
+
+ private final Type type;
+ private final String name;
+ private final String version;
+
+ public SystemCapability(Type type, String name, String version) {
+ this.type = type;
+ this.name = name;
+ this.version = version;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironment.java b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironment.java
new file mode 100644
index 0000000..57732c3
--- /dev/null
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironment.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.core.ee;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
+import org.eclipse.tycho.core.ee.shared.SystemCapability;
+import org.eclipse.tycho.core.ee.shared.SystemCapability.Type;
+import org.osgi.framework.Constants;
+
+public class CustomExecutionEnvironment implements ExecutionEnvironment {
+ private static final Pattern VERSION_NUMBER_DOT_NUMBER_DOT_ZERO_PATTERN = Pattern.compile("(\\d+\\.\\d+)\\.0");
+ private static final Pattern JAVA_SECOND_EDITION_VERSIONS_PATTERN = Pattern.compile("(1\\.[0-5])");
+
+ private final String profileName;
+ private final List<String> systemPackages = new ArrayList<String>();
+ private final Properties properties = new Properties();
+
+ // BEGIN construction
+
+ public CustomExecutionEnvironment(String profileName, List<SystemCapability> systemCapabilities) {
+ this.profileName = profileName;
+ setSystemPackages(systemCapabilities);
+ setExecutionEnvironmentProperties(systemCapabilities);
+ setOsgiSystemCapabilities(systemCapabilities);
+ }
+
+ private void setSystemPackages(List<SystemCapability> systemCapabilities) {
+ StringBuilder systemPackagesProperty = new StringBuilder();
+ for (SystemCapability capability : systemCapabilities) {
+ if (capability.getType() == Type.JAVA_PACKAGE) {
+ final String packageName = capability.getName();
+ systemPackages.add(packageName);
+ append(systemPackagesProperty, toPackageSpecifier(packageName, capability.getVersion()));
+ }
+ }
+ setPropertyIfNotEmpty(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackagesProperty);
+ }
+
+ 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);
+ }
+
+ private static final class MultipleVersionsCapability {
+ final String name;
+ int count = 0;
+ final StringBuilder versions = new StringBuilder();
+
+ public MultipleVersionsCapability(String environmentName, String version) {
+ name = environmentName;
+ addVersion(version);
+ }
+
+ private void addVersion(String version) {
+ if (count > 0) {
+ versions.append(", ");
+ }
+ versions.append(version);
+ count++;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder result = new StringBuilder();
+ result.append("osgi.ee; osgi.ee=\"" + name + "\"; ");
+ if (count <= 1) {
+ result.append("version:Version=\"");
+ } else {
+ result.append("version:List<Version>=\"");
+ }
+ result.append(versions);
+ result.append("\"");
+ return result.toString();
+ }
+ }
+
+ private void setOsgiSystemCapabilities(List<SystemCapability> systemCapabilities) {
+ Map<String, MultipleVersionsCapability> capabilityMap = new LinkedHashMap<String, MultipleVersionsCapability>();
+ 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 (String environmentName : capabilityMap.keySet()) {
+ MultipleVersionsCapability capability = capabilityMap.get(environmentName);
+ append(systemCapabilitesProperty, capability.toString());
+ }
+
+ setPropertyIfNotEmpty(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilitesProperty);
+ }
+
+ private void setPropertyIfNotEmpty(String key, StringBuilder value) {
+ if (value.length() > 0) {
+ properties.setProperty(key, value.toString());
+ }
+ }
+
+ private static void append(StringBuilder propertyValue, final String value) {
+ if (propertyValue.length() > 0) {
+ propertyValue.append(",");
+ }
+ propertyValue.append(value);
+ }
+
+ private String normalizeVersion(String version) {
+ final Matcher matcher = VERSION_NUMBER_DOT_NUMBER_DOT_ZERO_PATTERN.matcher(version);
+ if (matcher.matches()) {
+ return matcher.group(1);
+ }
+ return version;
+ }
+
+ private String toExecutionEnvironment(String environmentName, String version) {
+ if ("JavaSE".equals(environmentName)) {
+ if (JAVA_SECOND_EDITION_VERSIONS_PATTERN.matcher(version).matches()) {
+ return appendVersion("J2SE", version);
+ }
+ }
+ if ("CDC/Foundation".equals(environmentName)) {
+ return appendVersion("CDC", version) + "/" + appendVersion("Foundation", version);
+ }
+ return appendVersion(environmentName, version);
+ }
+
+ private String appendVersion(String value, String version) {
+ return value + "-" + version;
+ }
+
+ private String toPackageSpecifier(String packageName, String packageVersion) {
+ if (packageVersion != null) {
+ return packageName + ";version=\"" + packageVersion + "\"";
+ } else {
+ return packageName;
+ }
+ }
+
+ // END construction
+
+ public String getProfileName() {
+ return profileName;
+ }
+
+ public Properties getProfileProperties() {
+ return properties;
+ }
+
+ public String[] getSystemPackages() {
+ return systemPackages.toArray(new String[0]);
+ }
+
+ // not known for custom profiles
+ public String getCompilerSourceLevel() {
+ return null;
+ }
+
+ public String getCompilerTargetLevel() {
+ return null;
+ }
+
+ public boolean isCompatibleCompilerTargetLevel(String target) {
+ return true;
+ }
+}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java
index b388610..830bc9b 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java
@@ -120,6 +120,11 @@ public class ExecutionEnvironmentUtils {
if (ee != null)
properties.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
}
+ if (properties.getProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES) == null) {
+ String systemCapabilities = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES);
+ if (systemCapabilities != null)
+ properties.put(Constants.FRAMEWORK_SYSTEMCAPABILITIES, systemCapabilities);
+ }
}
private static Properties findVMProfile(Properties properties) {
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironmentTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironmentTest.java
new file mode 100644
index 0000000..b891240
--- /dev/null
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/ee/CustomExecutionEnvironmentTest.java
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2012 SAP AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tycho.core.ee;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.tycho.core.ee.shared.SystemCapability;
+import org.eclipse.tycho.core.ee.shared.SystemCapability.Type;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+
+@SuppressWarnings("deprecation")
+public class CustomExecutionEnvironmentTest {
+
+ private static final SystemCapability PACKAGE_JAVA_LANG = new SystemCapability(Type.JAVA_PACKAGE, "java.lang", null);
+ private static final SystemCapability PACKAGE_JAVAX_ACTIVATION_1_1 = new SystemCapability(Type.JAVA_PACKAGE,
+ "javax.activation", "1.1");
+ private static final SystemCapability OSGI_JAVASE_1_6 = new SystemCapability(Type.OSGI_EE, "JavaSE", "1.6.0");
+ private static final SystemCapability OSGI_JAVASE_1_7 = new SystemCapability(Type.OSGI_EE, "JavaSE", "1.7.0");
+ private static final SystemCapability OSGI_OSGIMINIMUM_1_0 = new SystemCapability(Type.OSGI_EE, "OSGi/Minimum",
+ "1.0.0");
+
+ private CustomExecutionEnvironment customExecutionEnvironment;
+
+ @Test
+ public void testEmptyExecutionEnvironment() {
+ createExecutionEnvironment();
+
+ assertThat(customExecutionEnvironment.getProfileName(), is("name"));
+ assertThat(customExecutionEnvironment.getCompilerSourceLevel(), is(nullValue()));
+ assertThat(customExecutionEnvironment.getCompilerTargetLevel(), is(nullValue()));
+ assertThat(customExecutionEnvironment.getSystemPackages(), is(new String[] {}));
+ assertThat(customExecutionEnvironment.getProfileProperties(), is(new Properties()));
+ }
+
+ @Test
+ public void testProvidedSystemPackageNoVersion() throws Exception {
+ createExecutionEnvironment(PACKAGE_JAVA_LANG);
+
+ assertThat(customExecutionEnvironment.getSystemPackages(), is(new String[] { "java.lang" }));
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(1));
+ assertProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, "java.lang");
+ }
+
+ @Test
+ public void testProvidedSystemPackageWithVersion() throws Exception {
+ createExecutionEnvironment(PACKAGE_JAVAX_ACTIVATION_1_1);
+
+ assertThat(customExecutionEnvironment.getSystemPackages(), is(new String[] { "javax.activation" }));
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(1));
+ assertProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, "javax.activation;version=\"1.1\"");
+ }
+
+ @Test
+ public void testTwoProvidedSystemPackages() throws Exception {
+ createExecutionEnvironment(PACKAGE_JAVA_LANG, PACKAGE_JAVAX_ACTIVATION_1_1);
+
+ assertThat(customExecutionEnvironment.getSystemPackages(), is(new String[] { "java.lang", "javax.activation" }));
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(1));
+ assertProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, "java.lang,javax.activation;version=\"1.1\"");
+ }
+
+ @Test
+ public void testOsgiEeCapability() throws Exception {
+ createExecutionEnvironment(OSGI_JAVASE_1_6);
+
+ assertThat(customExecutionEnvironment.getSystemPackages(), is(new String[] {}));
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(2));
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES, "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"1.6\"");
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-1.6");
+ }
+
+ @Test
+ public void testTwoOsgiEeCapabilities() throws Exception {
+ createExecutionEnvironment(OSGI_JAVASE_1_6, OSGI_OSGIMINIMUM_1_0);
+
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(2));
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES, "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"1.6\","
+ + "osgi.ee; osgi.ee=\"OSGi/Minimum\"; version:Version=\"1.0\"");
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-1.6,OSGi/Minimum-1.0");
+ }
+
+ @Test
+ public void testOsgiEeCapabilityInTwoVersions() throws Exception {
+ createExecutionEnvironment(OSGI_JAVASE_1_6, OSGI_JAVASE_1_7);
+
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(2));
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-1.6,JavaSE-1.7");
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES,
+ "osgi.ee; osgi.ee=\"JavaSE\"; version:List<Version>=\"1.6, 1.7\"");
+ }
+
+ @Test
+ public void testOsgiEeCapabilityStrangeVersion() throws Exception {
+ createExecutionEnvironment(new SystemCapability(Type.OSGI_EE, "JavaSE", "1.6.1"));
+
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(2));
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-1.6.1");
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES, "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"1.6.1\"");
+ }
+
+ @Test
+ public void testOsgiEeCapabilityAlphanumericVersion() throws Exception {
+ createExecutionEnvironment(new SystemCapability(Type.OSGI_EE, "JavaSE", "AlphaRelease.beta-245.0"));
+
+ assertThat(customExecutionEnvironment.getProfileProperties().size(), is(2));
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "JavaSE-AlphaRelease.beta-245.0");
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES,
+ "osgi.ee; osgi.ee=\"JavaSE\"; version:Version=\"AlphaRelease.beta-245.0\"");
+ }
+
+ @Test
+ public void testJavaSEVersionNameMappings() throws Exception {
+ List<SystemCapability> javaSeVersions = new ArrayList<SystemCapability>();
+ 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(2));
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT,
+ "J2SE-1.2,J2SE-1.3,J2SE-1.4,J2SE-1.5,JavaSE-1.6,JavaSE-1.7");
+ }
+
+ @Test
+ public void testCDCNameMapping() throws Exception {
+ createExecutionEnvironment(new SystemCapability(Type.OSGI_EE, "CDC/Foundation", "1.0"), new SystemCapability(
+ Type.OSGI_EE, "CDC/Foundation", "1.1.0"));
+
+ assertProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, "CDC-1.0/Foundation-1.0,CDC-1.1/Foundation-1.1");
+ assertProperty(Constants.FRAMEWORK_SYSTEMCAPABILITIES,
+ "osgi.ee; osgi.ee=\"CDC/Foundation\"; version:List<Version>=\"1.0, 1.1\"");
+ }
+
+ private void createExecutionEnvironment(SystemCapability... capabilities) {
+ customExecutionEnvironment = new CustomExecutionEnvironment("name", Arrays.asList(capabilities));
+ }
+
+ private void assertProperty(String key, String value) {
+ assertThat(customExecutionEnvironment.getProfileProperties().getProperty(key), is(value));
+ }
+}
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java
index 8c545bc..4545222 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java
@@ -10,7 +10,11 @@
*******************************************************************************/
package org.eclipse.tycho.core.test;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
import java.io.File;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -21,7 +25,10 @@ import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.tycho.artifacts.DependencyArtifacts;
import org.eclipse.tycho.core.TychoConstants;
+import org.eclipse.tycho.core.ee.CustomExecutionEnvironment;
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
+import org.eclipse.tycho.core.ee.shared.SystemCapability;
+import org.eclipse.tycho.core.ee.shared.SystemCapability.Type;
import org.eclipse.tycho.core.osgitools.DependencyComputer;
import org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry;
import org.eclipse.tycho.core.osgitools.EquinoxResolver;
@@ -30,13 +37,15 @@ import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.testing.AbstractTychoMojoTestCase;
import org.junit.Assert;
import org.junit.Test;
+import org.osgi.framework.Constants;
public class DependencyComputerTest extends AbstractTychoMojoTestCase {
private DependencyComputer dependencyComputer;
+ @Override
protected void setUp() throws Exception {
super.setUp();
- dependencyComputer = (DependencyComputer) lookup(DependencyComputer.class);
+ dependencyComputer = lookup(DependencyComputer.class);
}
@Override
@@ -79,4 +88,34 @@ public class DependencyComputerTest extends AbstractTychoMojoTestCase {
Assert.assertEquals(0, result.getProject().getDependencies().size());
}
+
+ // TODO code reuse
+ @Test
+ public void testWiringToPackageFromCustomProfile() throws Exception {
+ File basedir = getBasedir("projects/customProfile");
+ EquinoxResolver resolver = lookup(EquinoxResolver.class);
+
+ 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, platform);
+ BundleDescription bundle = state.getBundleByLocation(project.getBasedir().getCanonicalPath());
+
+ 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));
+ }
+ }
}
diff --git a/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/META-INF/MANIFEST.MF b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..0a7fd02
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Alternative provider of a package also available in the custom EE profile
+Bundle-SymbolicName: alternativeProvider
+Bundle-Version: 0.0.1
+Bundle-RequiredExecutionEnvironment: J2SE-1.2
+Export-Package: package.historically.not.in.jdk;version="1.2.1"
diff --git a/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/build.properties b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/pom.xml b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/pom.xml
new file mode 100644
index 0000000..ff43fd1
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/alternativeProvider/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>customProfile</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1</version>
+ </parent>
+
+ <artifactId>alternativeProvider</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+</project> \ No newline at end of file
diff --git a/tycho-core/src/test/resources/projects/customProfile/bundle/META-INF/MANIFEST.MF b/tycho-core/src/test/resources/projects/customProfile/bundle/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..6659eea
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/bundle/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle Plug-in
+Bundle-SymbolicName: bundle
+Bundle-Version: 0.0.1
+Bundle-RequiredExecutionEnvironment: J2SE-1.2
+Import-Package: package.historically.not.in.jdk;version="1.2.1"
diff --git a/tycho-core/src/test/resources/projects/customProfile/bundle/build.properties b/tycho-core/src/test/resources/projects/customProfile/bundle/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/bundle/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/tycho-core/src/test/resources/projects/customProfile/bundle/pom.xml b/tycho-core/src/test/resources/projects/customProfile/bundle/pom.xml
new file mode 100644
index 0000000..bce79a6
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/bundle/pom.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>customProfile</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1</version>
+ </parent>
+
+ <artifactId>bundle</artifactId>
+ <packaging>eclipse-plugin</packaging>
+
+</project> \ No newline at end of file
diff --git a/tycho-core/src/test/resources/projects/customProfile/pom.xml b/tycho-core/src/test/resources/projects/customProfile/pom.xml
new file mode 100644
index 0000000..6c9c048
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/customProfile/pom.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>customProfile</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.0.1</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>bundle</module>
+ <module>alternativeProvider</module>
+ </modules>
+
+</project>