|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2008, 2022 IBM Corporation and others. |
| 2 | + * Copyright (c) 2008, 2026 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
@@ -217,6 +217,9 @@ public static IProject createPluginProject(String bundleSymbolicName, String ver |
217 | 217 | case Constants.EXPORT_PACKAGE -> setPackageExports(description, projectService, value); |
218 | 218 | case Constants.IMPORT_PACKAGE -> setPackageImports(description, projectService, value); |
219 | 219 | case Constants.REQUIRE_BUNDLE -> setRequiredBundles(description, projectService, value); |
| 220 | + case Constants.FRAGMENT_HOST -> setFragmentHost(description, projectService, value); |
| 221 | + case Constants.REQUIRE_CAPABILITY -> setRequiredCapability(description, projectService, value); |
| 222 | + case Constants.PROVIDE_CAPABILITY -> setProvidedCapability(description, projectService, value); |
220 | 223 | default -> throw new IllegalArgumentException("Unsupported header: " + header); |
221 | 224 | } |
222 | 225 | }); |
@@ -256,6 +259,26 @@ private static void setRequiredBundles(IBundleProjectDescription project, IBundl |
256 | 259 | project.setRequiredBundles(imports); |
257 | 260 | } |
258 | 261 |
|
| 262 | + private static void setFragmentHost(IBundleProjectDescription project, IBundleProjectService projectService, |
| 263 | + String value) { |
| 264 | + var host = parseHeader(Constants.REQUIRE_BUNDLE, value, h -> { |
| 265 | + VersionRange bundleVersion = Optional.ofNullable(h.getAttribute(Constants.BUNDLE_VERSION)) |
| 266 | + .map(VersionRange::valueOf).orElse(null); |
| 267 | + return projectService.newHost(h.getValue(), bundleVersion); |
| 268 | + }).findFirst().orElse(null); |
| 269 | + project.setHost(host); |
| 270 | + } |
| 271 | + |
| 272 | + private static void setRequiredCapability(IBundleProjectDescription project, IBundleProjectService projectService, |
| 273 | + String value) { |
| 274 | + project.setHeader(Constants.REQUIRE_CAPABILITY, value); |
| 275 | + } |
| 276 | + |
| 277 | + private static void setProvidedCapability(IBundleProjectDescription project, IBundleProjectService projectService, |
| 278 | + String value) { |
| 279 | + project.setHeader(Constants.PROVIDE_CAPABILITY, value); |
| 280 | + } |
| 281 | + |
259 | 282 | private static <T> Stream<T> parseHeader(String header, String value, Function<ManifestElement, T> parser) { |
260 | 283 | try { |
261 | 284 | return Arrays.stream(ManifestElement.parseHeader(header, value)).map(parser); |
|
0 commit comments