Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-11-22 17:45:38 +0000
committerIgor Fedorenko2011-11-22 17:45:38 +0000
commit0602c214478fb06ef21ba68c4903224f46c6563e (patch)
tree7930140a1c74cb8b033866dc29153b337803e7c5
parent0e00411d75055b388dba4513421e4b63c90f738e (diff)
downloadorg.eclipse.tycho-0602c214478fb06ef21ba68c4903224f46c6563e.tar.gz
org.eclipse.tycho-0602c214478fb06ef21ba68c4903224f46c6563e.tar.xz
org.eclipse.tycho-0602c214478fb06ef21ba68c4903224f46c6563e.zip
364095 specify minimal build execution environment in pom.xml
For large multi-module projects, it is convenient to specify default build minimal execution environment in parent pom.xml but still allow individual module projects use higher execution environment if specified in bundle manifest. To support this usecase, pom.xml execution environment configuration parameter allows ? profile name prefix, i.e. <executionEnvironment>?J2SE-1.4</executionEnvironment>, which tells Tycho to treat specified EE as required minimal but use higher EE if so required by bundle manifest. For backwards compatibility with PDE, build.properties jre.compilation.profile entry takes precedence over ?profile specified in pom.xlm. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java10
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java56
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java3
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java23
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-hard/META-INF/MANIFEST.MF8
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-hard/build.properties4
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-hard/pom.xml28
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/META-INF/MANIFEST.MF8
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/build.properties4
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/pom.xml28
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-manifest/META-INF/MANIFEST.MF8
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-manifest/build.properties3
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom-soft-manifest/pom.xml28
-rw-r--r--tycho-core/src/test/resources/projects/bree/pom.xml16
-rw-r--r--tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java8
15 files changed, 213 insertions, 22 deletions
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
index 75d021dd0..0949f3c4a 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
@@ -88,11 +88,15 @@ public abstract class AbstractTychoProject extends AbstractLogEnabled implements
}
public ExecutionEnvironment getExecutionEnvironment(MavenProject project) {
- String ee = TychoProjectUtils.getTargetPlatformConfiguration(project).getExecutionEnvironment();
+ String profile = TychoProjectUtils.getTargetPlatformConfiguration(project).getExecutionEnvironment();
+
+ if (profile != null) {
+ if (profile.startsWith("?")) {
+ profile = profile.substring(1);
+ }
- if (ee != null) {
try {
- return ExecutionEnvironmentUtils.getExecutionEnvironment(ee);
+ return ExecutionEnvironmentUtils.getExecutionEnvironment(profile);
} catch (UnknownEnvironmentException e) {
// can't happen, ee is validated during configuration parsing
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
index a18761512..efce5c954 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
@@ -52,6 +52,7 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProjectImpl;
import org.eclipse.tycho.core.utils.ExecutionEnvironment;
import org.eclipse.tycho.core.utils.ExecutionEnvironmentUtils;
import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.model.Feature;
import org.eclipse.tycho.model.ProductConfiguration;
import org.eclipse.tycho.model.UpdateSite;
@@ -227,6 +228,7 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro
}
public List<ClasspathEntry> getClasspath(MavenProject project) {
+ @SuppressWarnings("unchecked")
List<ClasspathEntry> classpath = (List<ClasspathEntry>) project
.getContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_CLASSPATH);
if (classpath == null) {
@@ -426,29 +428,47 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro
}
public ExecutionEnvironment getExecutionEnvironment(MavenProject project) {
- ExecutionEnvironment explicitEE = super.getExecutionEnvironment(project);
+ String profile = TychoProjectUtils.getTargetPlatformConfiguration(project).getExecutionEnvironment();
- if (explicitEE != null) {
- // explicitly configured environment wins
- return explicitEE;
+ if (profile != null && !profile.startsWith("?")) {
+ // hard profile name in pom.xml
+ return getExecutionEnvironment(project, profile);
+ } else {
+ // PDE compatibility (I really feel generous today)
+ String pdeProfile = getEclipsePluginProject(DefaultReactorProject.adapt(project)).getBuildProperties()
+ .getProperty("jre.compilation.profile");
+ if (pdeProfile != null) {
+ return getExecutionEnvironment(project, pdeProfile.trim());
+ }
}
- // PDE compatibility (I really feel generous today)
- String ee = getEclipsePluginProject(DefaultReactorProject.adapt(project)).getBuildProperties().getProperty(
- "jre.compilation.profile");
- if (ee != null) {
- try {
- return ExecutionEnvironmentUtils.getExecutionEnvironment(ee.trim());
- } catch (UnknownEnvironmentException e) {
- throw new RuntimeException("Unknown execution environment specified in build.properties of project "
- + project, e);
- }
+ ExecutionEnvironment buildMinimalEE = null;
+
+ if (profile != null) {
+ buildMinimalEE = getExecutionEnvironment(project, profile.substring(1));
+ }
+
+ List<ExecutionEnvironment> envs = new ArrayList<ExecutionEnvironment>(Arrays.asList(getManifest(project)
+ .getExecutionEnvironments()));
+ if (envs.isEmpty()) {
+ return buildMinimalEE;
}
- ExecutionEnvironment[] requiredExecEnvs = getManifest(project).getExecutionEnvironments();
- if (requiredExecEnvs.length == 0) {
- return null;
+ ExecutionEnvironment manifestMinimalEE = Collections.min(envs);
+
+ if (buildMinimalEE == null) {
+ return manifestMinimalEE;
+ }
+
+ return manifestMinimalEE.compareTo(buildMinimalEE) < 0 ? buildMinimalEE : manifestMinimalEE;
+ }
+
+ protected ExecutionEnvironment getExecutionEnvironment(MavenProject project, String profile) {
+ try {
+ return ExecutionEnvironmentUtils.getExecutionEnvironment(profile);
+ } catch (UnknownEnvironmentException e) {
+ throw new RuntimeException("Unknown execution environment specified in build.properties of project "
+ + project, e);
}
- return Collections.min(new ArrayList<ExecutionEnvironment>(Arrays.asList(requiredExecEnvs)));
}
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
index 53b5fe149..20b598d2c 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
@@ -120,7 +120,8 @@ public class DefaultTargetPlatformConfigurationReader {
String ee = eeDom.getValue().trim();
if (!"".equals(ee)) {
try {
- ExecutionEnvironmentUtils.getExecutionEnvironment(ee);
+ String profile = ee.startsWith("?") ? ee.substring(1) : ee;
+ ExecutionEnvironmentUtils.getExecutionEnvironment(profile);
} catch (UnknownEnvironmentException e) {
throw new RuntimeException("Invalid execution environment profile name " + ee);
}
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java
index 9b50a32f2..f6439f70c 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java
@@ -15,6 +15,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
@@ -31,6 +32,7 @@ import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.osgitools.DefaultBundleReader;
import org.eclipse.tycho.core.osgitools.OsgiBundleProject;
import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader;
+import org.eclipse.tycho.core.utils.TychoVersion;
import org.eclipse.tycho.testing.AbstractTychoMojoTestCase;
public class TychoTest extends AbstractTychoMojoTestCase {
@@ -293,4 +295,25 @@ public class TychoTest extends AbstractTychoMojoTestCase {
assertEquals("bar", env.getWs());
assertEquals("munchy", env.getArch());
}
+
+ public void testBundleRuntimeExecutionEnvironment() throws Exception {
+ File basedir = getBasedir("projects/bree");
+
+ Properties properties = new Properties();
+ properties.put("tycho-version", TychoVersion.getTychoVersion());
+
+ List<MavenProject> projects = getSortedProjects(basedir, properties, null);
+ assertEquals(4, projects.size());
+
+ TychoProject bundleProject = lookup(TychoProject.class, ArtifactKey.TYPE_ECLIPSE_PLUGIN);
+
+ assertEquals("executionenvironment.pom-hard", projects.get(1).getArtifactId());
+ assertEquals("OSGi/Minimum-1.2", bundleProject.getExecutionEnvironment(projects.get(1)).getProfileName());
+
+ assertEquals("executionenvironment.pom-soft-buildproperties", projects.get(2).getArtifactId());
+ assertEquals("OSGi/Minimum-1.1", bundleProject.getExecutionEnvironment(projects.get(2)).getProfileName());
+
+ assertEquals("executionenvironment.pom-soft-manifest", projects.get(3).getArtifactId());
+ assertEquals("OSGi/Minimum-1.2", bundleProject.getExecutionEnvironment(projects.get(3)).getProfileName());
+ }
}
diff --git a/tycho-core/src/test/resources/projects/bree/pom-hard/META-INF/MANIFEST.MF b/tycho-core/src/test/resources/projects/bree/pom-hard/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..b6bf75b8b
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-hard/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: executionenvironment.pom-hard
+Bundle-SymbolicName: executionenvironment.pom-hard
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.0,
+ OSGi/Minimum-1.1,
+ OSGi/Minimum-1.2
diff --git a/tycho-core/src/test/resources/projects/bree/pom-hard/build.properties b/tycho-core/src/test/resources/projects/bree/pom-hard/build.properties
new file mode 100644
index 000000000..68e3c7bd3
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-hard/build.properties
@@ -0,0 +1,4 @@
+jars.compile.order = .
+source.. = src/
+output.. = target/classes
+jre.compilation.profile = OSGi/Minimum-1.1
diff --git a/tycho-core/src/test/resources/projects/bree/pom-hard/pom.xml b/tycho-core/src/test/resources/projects/bree/pom-hard/pom.xml
new file mode 100644
index 000000000..c5a520c88
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-hard/pom.xml
@@ -0,0 +1,28 @@
+<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>executionenvironment</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>executionenvironment.pom-hard</artifactId>
+ <version>1.0.0</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <executionEnvironment>OSGi/Minimum-1.2</executionEnvironment>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/META-INF/MANIFEST.MF b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..8fc34a2eb
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: executionenvironment.pom-soft-buildproperties
+Bundle-SymbolicName: executionenvironment.pom-soft-buildproperties
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.0,
+ OSGi/Minimum-1.1,
+ OSGi/Minimum-1.2
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/build.properties b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/build.properties
new file mode 100644
index 000000000..68e3c7bd3
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/build.properties
@@ -0,0 +1,4 @@
+jars.compile.order = .
+source.. = src/
+output.. = target/classes
+jre.compilation.profile = OSGi/Minimum-1.1
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/pom.xml b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/pom.xml
new file mode 100644
index 000000000..f70469635
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-buildproperties/pom.xml
@@ -0,0 +1,28 @@
+<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>executionenvironment</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>executionenvironment.pom-soft-buildproperties</artifactId>
+ <version>1.0.0</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <executionEnvironment>?OSGi/Minimum-1.2</executionEnvironment>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/META-INF/MANIFEST.MF b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..537d4563a
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: executionenvironment.pom-soft-manifest
+Bundle-SymbolicName: executionenvironment.pom-soft-manifest
+Bundle-Version: 1.0.0
+Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.0,
+ OSGi/Minimum-1.1,
+ OSGi/Minimum-1.2
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/build.properties b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/build.properties
new file mode 100644
index 000000000..8e8276107
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/build.properties
@@ -0,0 +1,3 @@
+jars.compile.order = .
+source.. = src/
+output.. = target/classes
diff --git a/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/pom.xml b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/pom.xml
new file mode 100644
index 000000000..09beb6f2d
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/pom-soft-manifest/pom.xml
@@ -0,0 +1,28 @@
+<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>executionenvironment</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>executionenvironment.pom-soft-manifest</artifactId>
+ <version>1.0.0</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <executionEnvironment>?OSGi/Minimum-1.2</executionEnvironment>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tycho-core/src/test/resources/projects/bree/pom.xml b/tycho-core/src/test/resources/projects/bree/pom.xml
new file mode 100644
index 000000000..63ff9e10c
--- /dev/null
+++ b/tycho-core/src/test/resources/projects/bree/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>executionenvironment</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>pom-hard</module>
+ <module>pom-soft-buildproperties</module>
+ <module>pom-soft-manifest</module>
+ </modules>
+</project>
diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java
index 80f4c992f..8eb019ad7 100644
--- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java
+++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java
@@ -80,6 +80,11 @@ public class AbstractTychoMojoTestCase extends AbstractMojoTestCase {
}
protected List<MavenProject> getSortedProjects(File basedir, File platform) throws Exception {
+ return getSortedProjects(basedir, null, platform);
+ }
+
+ protected List<MavenProject> getSortedProjects(File basedir, Properties userProperties, File platform)
+ throws Exception {
File pom = new File(basedir, "pom.xml");
MavenExecutionRequest request = newMavenExecutionRequest(pom);
request.getProjectBuildingRequest().setProcessPlugins(false);
@@ -87,6 +92,9 @@ public class AbstractTychoMojoTestCase extends AbstractMojoTestCase {
if (platform != null) {
request.getUserProperties().put("tycho.targetPlatform", platform.getCanonicalPath());
}
+ if (userProperties != null) {
+ request.getUserProperties().putAll(userProperties);
+ }
MavenExecutionResult result = maven.execute(request);
if (result.hasExceptions()) {
throw new CompoundRuntimeException(result.getExceptions());

Back to the top