From 2235d3c69829caf19e38ea980a86042cc3ffd1f3 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Wed, 15 Mar 2023 21:28:25 +0100 Subject: [PATCH] Fully automate OSGi metadata creation and fix brocken OSGi-metadata in slf4j-api (#330) * Improve generated OSGi metadata and restore Bundle-SymbolicName Enhance the generated OSGi metadata for all slf4j-modules in the following ways: - Restore the Bundle-SymbolicName, Bundle-Name, Bundle-Vendor and Bundle-DocURL from SLF4J-2.0.5 and before - Removes Export-Package: META-INF.versions.9 - Removes self-Imports of exported package (has to be added again in a follow up, where desired) - Remove unnecessary BND-internal headers Additionally move the maven-bundle-plugin configuration from the execution configuration up into the configuration of the plugin so that it can be easier overwritten in child-modules. Signed-off-by: Hannes Wellmann * Automate OSGi metadata creation and restore package-exports of slf4j-api Only use the maven-bundle-plugin to generate all OSGi metadata into slf4j-api's Manifest.MF file. This unifies the resulting MANIFEST.MFs that are currently partly generated and partly statically defined. Furthermore it fixes the following flaws in the currently generated OSGi metadata of slf4j-api: - Import only the exported org.slf4j.spi package (like in slf4j 2.0.5 and before) - Replace the deprecated 'Bundle-RequiredExecutionEnvironment' header by a corresponding required 'osgi.ee' capability Signed-off-by: Hannes Wellmann --------- Signed-off-by: Hannes Wellmann --- pom.xml | 30 ++++++++++++------- slf4j-api/pom.xml | 14 +++++++++ .../src/main/resources/META-INF/MANIFEST.MF | 15 ---------- 3 files changed, 33 insertions(+), 26 deletions(-) delete mode 100755 slf4j-api/src/main/resources/META-INF/MANIFEST.MF diff --git a/pom.xml b/pom.xml index 076a0f2d3..3b1bcdc6a 100755 --- a/pom.xml +++ b/pom.xml @@ -241,6 +241,25 @@ org.apache.felix maven-bundle-plugin ${maven-bundle-plugin.version} + + true + + + ${replacestring;${project.artifactId};-;.} + ${project.artifactId} + SLF4J.ORG + <_snapshot/> + <_exportcontents>!META-INF.versions.9,*;-noimport:=true + ${project.description} + ${project.url} + ${maven.compiler.source} + ${maven.compiler.target} + ${project.version} + ${project.artifactId} + true + <_removeheaders>Private-Package,Bundle-SCM, Bundle-Developers, Include-Resource + + bundle-manifest @@ -248,17 +267,6 @@ manifest - - - - ${parsedVersion.osgiVersion} - ${project.description} - ${maven.compiler.source} - ${maven.compiler.target} - ${project.version} - true - - diff --git a/slf4j-api/pom.xml b/slf4j-api/pom.xml index 1a19a326e..37a8dee97 100755 --- a/slf4j-api/pom.xml +++ b/slf4j-api/pom.xml @@ -53,6 +53,20 @@ + + org.apache.felix + maven-bundle-plugin + + + org.slf4j.spi;version="${range;[===,+);${version;===;${maven_version;${project.version}}}}" + =1.0.0)(!(version>=2.0.0)))", + osgi.serviceloader;filter:="(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)";osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider" + ]]> + + + + diff --git a/slf4j-api/src/main/resources/META-INF/MANIFEST.MF b/slf4j-api/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100755 index eb0a28705..000000000 --- a/slf4j-api/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Implementation-Title: slf4j-api -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: slf4j.api -Bundle-Name: slf4j-api -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.slf4j;version=${parsedVersion.osgiVersion}, - org.slf4j.spi;version=${parsedVersion.osgiVersion}, - org.slf4j.helpers;version=${parsedVersion.osgiVersion}, - org.slf4j.event;version=${parsedVersion.osgiVersion} -Import-Package: org.slf4j.spi;version=${parsedVersion.osgiVersion} -Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.servi - celoader.processor)(version>=1.0.0)(!(version>=2.0.0)))",osgi.service - loader;filter:="(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvide - r)";osgi.serviceloader="org.slf4j.spi.SLF4JServiceProvider"