From cb670d6b1f476523f81d086dce27c5262d3a8402 Mon Sep 17 00:00:00 2001 From: "Klare, Heiko" Date: Wed, 11 Mar 2026 09:30:36 +0100 Subject: [PATCH] Make an independent bundle out of SWT SVG fragment org.eclipse.swt.svg was implemented as a fragment for the SWT host. This requires a complex setup due to the SVG fragment depending on the effective SWT API provided by the native fragments. With the SVG rasterizer being provided via an OSGi capability anyway, the reason for having the SVG bundle as a fragment became obsolete. This change makes org.eclipse.swt.svg an ordinary bundle. The according tests are extracted into a separate bundle as well, making the SWT tests properly independent from the tests for the specific SVG rasterizer. Contributes to https://github.com/eclipse-platform/eclipse.platform.swt/issues/3129 --- .../org.eclipse.swt.svg/META-INF/MANIFEST.MF | 11 +++-- bundles/org.eclipse.swt.svg/META-INF/p2.inf | 32 --------------- bundles/org.eclipse.swt.svg/build.properties | 11 +---- ...{fragment.properties => plugin.properties} | 2 +- bundles/org.eclipse.swt/META-INF/MANIFEST.MF | 4 +- pom.xml | 1 + tests/org.eclipse.swt.svg.tests/.classpath | 11 +++++ tests/org.eclipse.swt.svg.tests/.project | 41 +++++++++++++++++++ .../org.eclipse.core.resources.prefs | 2 + .../META-INF/MANIFEST.MF | 12 ++++++ .../build.properties | 7 ++++ .../src/org/eclipse/swt/svg/AllSVGTests.java | 21 ++++++++++ .../eclipse/swt/svg}/JSVGRasterizerTest.java | 13 +----- .../swt/tests/junit/AllNonBrowserTests.java | 1 - 14 files changed, 109 insertions(+), 60 deletions(-) delete mode 100644 bundles/org.eclipse.swt.svg/META-INF/p2.inf rename bundles/org.eclipse.swt.svg/{fragment.properties => plugin.properties} (93%) create mode 100644 tests/org.eclipse.swt.svg.tests/.classpath create mode 100644 tests/org.eclipse.swt.svg.tests/.project create mode 100644 tests/org.eclipse.swt.svg.tests/.settings/org.eclipse.core.resources.prefs create mode 100644 tests/org.eclipse.swt.svg.tests/META-INF/MANIFEST.MF create mode 100644 tests/org.eclipse.swt.svg.tests/build.properties create mode 100644 tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/AllSVGTests.java rename tests/{org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit => org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg}/JSVGRasterizerTest.java (86%) diff --git a/bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF index 7b905f69ddc..5d2302991e9 100644 --- a/bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.swt.svg/META-INF/MANIFEST.MF @@ -3,13 +3,16 @@ Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.swt.svg Bundle-Version: 3.132.100.qualifier Automatic-Module-Name: org.eclipse.swt.svg -Bundle-Name: %fragmentName +Bundle-ActivationPolicy: lazy +Bundle-Name: %pluginName Bundle-Vendor: %providerName -Bundle-Localization: fragment +Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-21 -Fragment-Host: org.eclipse.swt +Require-Bundle: org.eclipse.swt Import-Package: com.github.weisj.jsvg;version="[2.0.0,3.0.0)", com.github.weisj.jsvg.parser;version="[2.0.0,3.0.0)", com.github.weisj.jsvg.view;version="[2.0.0,3.0.0)" Export-Package: org.eclipse.swt.svg;x-internal:=true -Provide-Capability: eclipse.swt;image.format="svg";version:Version="1.0" +Provide-Capability: osgi.serviceloader;osgi.serviceloader="org.eclipse.swt.internal.image.SVGRasterizer", + eclipse.swt;image.format="svg";version:Version="1.0" +Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)" diff --git a/bundles/org.eclipse.swt.svg/META-INF/p2.inf b/bundles/org.eclipse.swt.svg/META-INF/p2.inf deleted file mode 100644 index 9818f97c079..00000000000 --- a/bundles/org.eclipse.swt.svg/META-INF/p2.inf +++ /dev/null @@ -1,32 +0,0 @@ -# ensure that the applicable implementation fragment gets installed (https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/3006) -requires.1.namespace = org.eclipse.equinox.p2.iu -requires.1.name = org.eclipse.swt.win32.win32.x86_64 -requires.1.filter = (&(osgi.os=win32)(osgi.ws=win32)(osgi.arch=x86_64)) - -requires.2.namespace = org.eclipse.equinox.p2.iu -requires.2.name = org.eclipse.swt.cocoa.macosx.x86_64 -requires.2.filter = (&(osgi.os=macosx)(osgi.ws=cocoa)(osgi.arch=x86_64)) - -requires.3.namespace = org.eclipse.equinox.p2.iu -requires.3.name = org.eclipse.swt.gtk.linux.x86_64 -requires.3.filter = (&(osgi.os=linux)(osgi.ws=gtk)(osgi.arch=x86_64)) - -requires.4.namespace = org.eclipse.equinox.p2.iu -requires.4.name = org.eclipse.swt.gtk.linux.ppc64le -requires.4.filter = (&(osgi.os=linux)(osgi.ws=gtk)(osgi.arch=ppc64le)) - -requires.5.namespace = org.eclipse.equinox.p2.iu -requires.5.name = org.eclipse.swt.gtk.linux.aarch64 -requires.5.filter = (&(osgi.os=linux)(osgi.ws=gtk)(osgi.arch=aarch64)) - -requires.6.namespace = org.eclipse.equinox.p2.iu -requires.6.name = org.eclipse.swt.cocoa.macosx.aarch64 -requires.6.filter = (&(osgi.os=macosx)(osgi.ws=cocoa)(osgi.arch=aarch64)) - -requires.7.namespace = org.eclipse.equinox.p2.iu -requires.7.name = org.eclipse.swt.win32.win32.aarch64 -requires.7.filter = (&(osgi.os=win32)(osgi.ws=win32)(osgi.arch=aarch64)) - -requires.8.namespace = org.eclipse.equinox.p2.iu -requires.8.name = org.eclipse.swt.gtk.linux.riscv64 -requires.8.filter = (&(osgi.os=linux)(osgi.ws=gtk)(osgi.arch=riscv64)) diff --git a/bundles/org.eclipse.swt.svg/build.properties b/bundles/org.eclipse.swt.svg/build.properties index 5c42651be32..816374508f3 100644 --- a/bundles/org.eclipse.swt.svg/build.properties +++ b/bundles/org.eclipse.swt.svg/build.properties @@ -17,15 +17,6 @@ source.. = src/,\ output.. = bin/ bin.includes = META-INF/,\ .,\ - fragment.properties,\ + plugin.properties,\ about.html src.includes = about.html - -jars.extra.classpath = platform:/plugin/org.eclipse.swt.cocoa.macosx.aarch64,\ - platform:/plugin/org.eclipse.swt.cocoa.macosx.x86_64,\ - platform:/plugin/org.eclipse.swt.gtk.linux.aarch64,\ - platform:/plugin/org.eclipse.swt.gtk.linux.ppc64le,\ - platform:/plugin/org.eclipse.swt.gtk.linux.riscv64,\ - platform:/plugin/org.eclipse.swt.gtk.linux.x86_64,\ - platform:/plugin/org.eclipse.swt.win32.win32.aarch64,\ - platform:/plugin/org.eclipse.swt.win32.win32.x86_64 diff --git a/bundles/org.eclipse.swt.svg/fragment.properties b/bundles/org.eclipse.swt.svg/plugin.properties similarity index 93% rename from bundles/org.eclipse.swt.svg/fragment.properties rename to bundles/org.eclipse.swt.svg/plugin.properties index 1ae8d5b50da..aca08332f56 100644 --- a/bundles/org.eclipse.swt.svg/fragment.properties +++ b/bundles/org.eclipse.swt.svg/plugin.properties @@ -10,5 +10,5 @@ # Contributors: # Michael Bangas (Vector Informatik GmbH) - initial API and implementation ############################################################################### -fragmentName = SWT SVG Rendering Support +pluginName = SWT SVG Rendering Support providerName = Eclipse.org diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF index 2210f931765..6c4a5921d7b 100644 --- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF @@ -16,7 +16,7 @@ Export-Package: org.eclipse.swt.events, org.eclipse.swt.graphics, org.eclipse.swt.internal;x-internal:=true, - org.eclipse.swt.internal.image;x-internal:=true, + org.eclipse.swt.internal.image;x-friends:="org.eclipse.swt.svg", org.eclipse.swt.layout, org.eclipse.swt.opengl, org.eclipse.swt.printing, @@ -25,3 +25,5 @@ Export-Package: Eclipse-ExtensibleAPI: true Bundle-RequiredExecutionEnvironment: JavaSE-21 Automatic-Module-Name: org.eclipse.swt +Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)(version>=1.0.0)(!(version>=2.0.0)))", + osgi.serviceloader;filter:="(osgi.serviceloader=org.eclipse.swt.internal.image.SVGRasterizer)";resolution:=optional diff --git a/pom.xml b/pom.xml index 65542e6862f..a3f362591c2 100644 --- a/pom.xml +++ b/pom.xml @@ -236,6 +236,7 @@ examples/org.eclipse.swt.examples.ole.win32 examples/org.eclipse.swt.examples.views tests/org.eclipse.swt.tests + tests/org.eclipse.swt.svg.tests features/org.eclipse.swt.tools.feature diff --git a/tests/org.eclipse.swt.svg.tests/.classpath b/tests/org.eclipse.swt.svg.tests/.classpath new file mode 100644 index 00000000000..1aa9eca95a0 --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tests/org.eclipse.swt.svg.tests/.project b/tests/org.eclipse.swt.svg.tests/.project new file mode 100644 index 00000000000..4362fd58090 --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/.project @@ -0,0 +1,41 @@ + + + org.eclipse.swt.svg.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + + + .settings/org.eclipse.jdt.core.prefs + 1 + SHARED_SETTINGS/org.eclipse.jdt.core.prefs + + + + + SHARED_SETTINGS + $%7BPARENT-2-PROJECT_LOC%7D/examples/.settings_shared + + + diff --git a/tests/org.eclipse.swt.svg.tests/.settings/org.eclipse.core.resources.prefs b/tests/org.eclipse.swt.svg.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/tests/org.eclipse.swt.svg.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.swt.svg.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..84b5294b599 --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Eclipse SWT Tests SVG +Fragment-Host: org.eclipse.swt.svg +Bundle-SymbolicName: org.eclipse.swt.svg.tests +Bundle-Version: 3.0.0.qualifier +Automatic-Module-Name: org.eclipse.swt.svg.tests +Bundle-RequiredExecutionEnvironment: JavaSE-21 +Import-Package: org.junit.jupiter.api;version="[5.14.0,6.0.0)", + org.junit.jupiter.api.function;version="[5.14.0,6.0.0)", + org.junit.platform.suite.api;version="[1.14.0,2.0.0)" + diff --git a/tests/org.eclipse.swt.svg.tests/build.properties b/tests/org.eclipse.swt.svg.tests/build.properties new file mode 100644 index 00000000000..46e29c2929a --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . + +pom.model.packaging = eclipse-test-plugin +pom.model.property.testClass = org.eclipse.swt.svg.AllSVGTests diff --git a/tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/AllSVGTests.java b/tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/AllSVGTests.java new file mode 100644 index 00000000000..a8b9e4f241a --- /dev/null +++ b/tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/AllSVGTests.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2026 Vector Informatik GmbH and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.swt.svg; + +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +@Suite +@SelectClasses({ // + JSVGRasterizerTest.class, // +}) +public class AllSVGTests { +} diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/JSVGRasterizerTest.java b/tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/JSVGRasterizerTest.java similarity index 86% rename from tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/JSVGRasterizerTest.java rename to tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/JSVGRasterizerTest.java index 995b4fa9327..3305ca87527 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/JSVGRasterizerTest.java +++ b/tests/org.eclipse.swt.svg.tests/src/org/eclipse/swt/svg/JSVGRasterizerTest.java @@ -11,9 +11,8 @@ * Contributors: * Yatta Solutions - initial API and implementation *******************************************************************************/ -package org.eclipse.swt.tests.junit; +package org.eclipse.swt.svg; -import static org.eclipse.swt.tests.junit.SwtTestUtil.assertSWTProblem; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -23,10 +22,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.svg.JSVGRasterizer; import org.junit.jupiter.api.Test; -@SuppressWarnings("restriction") class JSVGRasterizerTest { private final JSVGRasterizer rasterizer = new JSVGRasterizer(); @@ -51,13 +48,7 @@ void testRasterizeWithZoom() { @Test void testRasterizeWithZoomNegative() { - try { - rasterizer.rasterizeSVG(svgStream(svgString), -100); - - } catch (IllegalArgumentException e) { - assertSWTProblem("Incorrect exception thrown for negative zoom", SWT.ERROR_INVALID_ARGUMENT, e); - } - + assertThrows(IllegalArgumentException.class, () -> rasterizer.rasterizeSVG(svgStream(svgString), -100)); } @Test diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests.java index 6a1b0f41fac..06adef5fac4 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/AllNonBrowserTests.java @@ -48,7 +48,6 @@ public class AllNonBrowserTests { AllWidgetTests.class, // // Rest of tests alphabetically DPIUtilTests.class, // - JSVGRasterizerTest.class, // Test_org_eclipse_swt_accessibility_Accessible.class, // Test_org_eclipse_swt_accessibility_AccessibleControlEvent.class, // Test_org_eclipse_swt_accessibility_AccessibleEvent.class, //