|
21 | 21 | import java.util.Arrays; |
22 | 22 | import java.util.Collection; |
23 | 23 | import java.util.Set; |
| 24 | +import java.util.SortedSet; |
24 | 25 | import java.util.concurrent.TimeUnit; |
25 | 26 | import java.util.stream.Collectors; |
26 | 27 |
|
|
34 | 35 | import org.eclipse.core.runtime.IPath; |
35 | 36 | import org.eclipse.core.runtime.IProgressMonitor; |
36 | 37 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 38 | +import org.eclipse.jdt.launching.JavaRuntime; |
| 39 | +import org.eclipse.jdt.launching.environments.IExecutionEnvironment; |
| 40 | +import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager; |
37 | 41 | import org.eclipse.pde.core.plugin.IPluginModelBase; |
38 | 42 | import org.eclipse.pde.ds.internal.annotations.Messages; |
39 | 43 | import org.eclipse.pde.internal.core.ICoreConstants; |
@@ -117,7 +121,15 @@ private static void createProjectWithTemplate() |
117 | 121 | data.setHasBundleStructure(true); |
118 | 122 | data.setSourceFolderName("src"); |
119 | 123 | data.setOutputFolderName("bin"); |
120 | | - data.setExecutionEnvironment("JavaSE-" + Runtime.version().feature()); |
| 124 | + IExecutionEnvironmentsManager executionEnvironmentsManager = JavaRuntime.getExecutionEnvironmentsManager(); |
| 125 | + IExecutionEnvironment environment = executionEnvironmentsManager |
| 126 | + .getEnvironment("JavaSE-" + Runtime.version().feature()); |
| 127 | + SortedSet<IExecutionEnvironment> supportedExecutionEnvironments = executionEnvironmentsManager |
| 128 | + .getSupportedExecutionEnvironments(); |
| 129 | + if (!supportedExecutionEnvironments.contains(environment)) { |
| 130 | + environment = supportedExecutionEnvironments.last(); |
| 131 | + } |
| 132 | + data.setExecutionEnvironment(environment.getId()); |
121 | 133 | data.setTargetVersion(ICoreConstants.TARGET_VERSION_LATEST); |
122 | 134 | data.setDoGenerateClass(true); |
123 | 135 | String pureOSGi = template.getConfigurationElement().getAttribute("pureOSGi"); |
|
0 commit comments