|
65 | 65 | import org.eclipse.aether.resolution.DependencyResolutionException;
|
66 | 66 | import org.eclipse.jdt.internal.compiler.util.CtSym;
|
67 | 67 | import org.eclipse.jdt.internal.compiler.util.JRTUtil;
|
68 |
| -import org.eclipse.osgi.util.ManifestElement; |
69 | 68 | import org.eclipse.tycho.ArtifactKey;
|
70 | 69 | import org.eclipse.tycho.ClasspathEntry;
|
71 | 70 | import org.eclipse.tycho.ClasspathEntry.AccessRule;
|
|
98 | 97 | import org.eclipse.tycho.model.classpath.M2ClasspathVariable;
|
99 | 98 | import org.eclipse.tycho.model.classpath.PluginDependenciesClasspathContainer;
|
100 | 99 | import org.eclipse.tycho.model.classpath.ProjectClasspathEntry;
|
101 |
| -import org.osgi.framework.Constants; |
102 |
| -import org.osgi.framework.Filter; |
103 |
| -import org.osgi.framework.FrameworkUtil; |
104 |
| -import org.osgi.framework.InvalidSyntaxException; |
105 | 100 | import org.osgi.framework.Version;
|
106 |
| -import org.osgi.framework.namespace.ExecutionEnvironmentNamespace; |
107 |
| -import org.osgi.resource.Namespace; |
108 | 101 |
|
109 | 102 | import copied.org.apache.maven.plugin.AbstractCompilerMojo;
|
110 | 103 |
|
@@ -348,7 +341,7 @@ public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo impl
|
348 | 341 | @Component
|
349 | 342 | private MavenDependenciesResolver dependenciesResolver;
|
350 | 343 |
|
351 |
| - private StandardExecutionEnvironment[] manifestBREEs; |
| 344 | + private ExecutionEnvironment[] manifestBREEs; |
352 | 345 |
|
353 | 346 | private File currentOutputDirectory;
|
354 | 347 |
|
@@ -458,45 +451,15 @@ protected void doFinish() throws MojoExecutionException {
|
458 | 451 | /**
|
459 | 452 | * Only public for tests purpose!
|
460 | 453 | */
|
461 |
| - public StandardExecutionEnvironment[] getBREE() { |
| 454 | + public ExecutionEnvironment[] getBREE() { |
462 | 455 | if (currentRelease != null) {
|
463 | 456 | //if there is an explicit release set we know the release and there must be a suitable EE provided
|
464 | 457 | return new StandardExecutionEnvironment[] { ExecutionEnvironmentUtils
|
465 | 458 | .getExecutionEnvironment("JavaSE-" + currentRelease, toolchainManager, session, logger) };
|
466 | 459 | }
|
467 | 460 | if (manifestBREEs == null) {
|
468 |
| - OsgiManifest manifest = bundleReader.loadManifest(project.getBasedir()); |
469 |
| - manifestBREEs = Arrays.stream(manifest.getExecutionEnvironments()) |
470 |
| - .map(ee -> ExecutionEnvironmentUtils.getExecutionEnvironment(ee, toolchainManager, session, logger)) |
471 |
| - .toArray(StandardExecutionEnvironment[]::new); |
472 |
| - if (manifestBREEs.length == 0) { |
473 |
| - ManifestElement[] requireCapability = manifest.getManifestElements(Constants.REQUIRE_CAPABILITY); |
474 |
| - if (requireCapability != null) { |
475 |
| - List<Filter> eeFilters = Arrays.stream(requireCapability) |
476 |
| - .filter(element -> ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE |
477 |
| - .equals(element.getValue())) // |
478 |
| - .map(element -> element.getDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE)) // |
479 |
| - .map(filterDirective -> { |
480 |
| - try { |
481 |
| - return FrameworkUtil.createFilter(filterDirective); |
482 |
| - } catch (InvalidSyntaxException e) { |
483 |
| - e.printStackTrace(); |
484 |
| - return null; |
485 |
| - } |
486 |
| - }).filter(Objects::nonNull).toList(); |
487 |
| - manifestBREEs = ExecutionEnvironmentUtils.getProfileNames(toolchainManager, session, logger) |
488 |
| - .stream() // |
489 |
| - .map(name -> name.split("-")) // |
490 |
| - .map(segments -> Map.of(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, |
491 |
| - segments[0], "version", segments[1])) |
492 |
| - .filter(eeCapability -> eeFilters.stream().anyMatch(filter -> filter.matches(eeCapability))) |
493 |
| - .map(ee -> ee.get(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE) + '-' |
494 |
| - + ee.get("version")) |
495 |
| - .map(ee -> ExecutionEnvironmentUtils.getExecutionEnvironment(ee, toolchainManager, session, |
496 |
| - logger)) |
497 |
| - .toArray(StandardExecutionEnvironment[]::new); |
498 |
| - } |
499 |
| - } |
| 461 | + manifestBREEs = tychoProjectManager.getExecutionEnvironments(project, session) |
| 462 | + .toArray(ExecutionEnvironment[]::new); |
500 | 463 | }
|
501 | 464 | return manifestBREEs;
|
502 | 465 | }
|
@@ -828,7 +791,7 @@ private List<AccessRule> getStrictBootClasspathAccessRules() throws MojoExecutio
|
828 | 791 |
|
829 | 792 | private void configureJavaHome(CompilerConfiguration compilerConfiguration) throws MojoExecutionException {
|
830 | 793 | if (useJDK == JDKUsage.BREE) {
|
831 |
| - StandardExecutionEnvironment[] brees = getBREE(); |
| 794 | + ExecutionEnvironment[] brees = getBREE(); |
832 | 795 | String toolchainId;
|
833 | 796 | if (brees.length > 0) {
|
834 | 797 | toolchainId = brees[0].getProfileName();
|
@@ -1155,9 +1118,9 @@ public String getReleaseLevel() throws MojoExecutionException {
|
1155 | 1118 | }
|
1156 | 1119 |
|
1157 | 1120 | private void checkTargetLevelCompatibleWithManifestBREEs(String effectiveTargetLevel,
|
1158 |
| - StandardExecutionEnvironment[] manifestBREEs) throws MojoExecutionException { |
| 1121 | + ExecutionEnvironment[] manifestBREEs) throws MojoExecutionException { |
1159 | 1122 | List<String> incompatibleBREEs = new ArrayList<>();
|
1160 |
| - for (StandardExecutionEnvironment ee : manifestBREEs) { |
| 1123 | + for (ExecutionEnvironment ee : manifestBREEs) { |
1161 | 1124 | if (!ee.isCompatibleCompilerTargetLevel(effectiveTargetLevel)) {
|
1162 | 1125 | incompatibleBREEs.add(ee.getProfileName() + " (assumes " + ee.getCompilerTargetLevelDefault() + ")");
|
1163 | 1126 | }
|
|
0 commit comments