Skip to content

Commit

Permalink
Fully automate OSGi metadata creation and implement minor fixes
Browse files Browse the repository at this point in the history
Only use the maven-bundle-plugin to generate all OSGi metadata into
slf4j's Manifest.MF files. This unifies the resulting MANIFEST.MFs that
are currently partly generated and partly statically defined and fixes
the following aspects:

- Restore the Bundle-SymbolicName from SLF4J-2.0.5 and before
- Generate the OSGi 'Service Loader Mediator' capabilities for all
SLF4JServiceProviders using BND-Tools
- Removes Exported-Packages: META-INF.versions.9
- Restricts the slf4j self import versions to [<current-version>,3)
- Add Automatic-Module headers for those artifacts that don't have a
module-info.java
- Replace the deprecated 'Bundle-RequiredExecutionEnvironment' by a
corresponding required 'osgi.ee' capability.
- Fix the package-export of slf4j-jdk-platform-logging (from
'slf4j.jdk.platform.logging' to 'org.slf4j.jdk.platform.logging')
- Adds the 'Main-Class' header for the migrator artifact again(?)

Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
  • Loading branch information
HannesWell committed Dec 14, 2022
1 parent b1c27a1 commit e10feb8
Show file tree
Hide file tree
Showing 27 changed files with 176 additions and 165 deletions.
Empty file.
14 changes: 14 additions & 0 deletions jcl-over-slf4j/pom.xml
Expand Up @@ -39,5 +39,19 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>org.apache.commons.logging.*;version=${jcl.version}</Export-Package>
</instructions>
</configuration>
</plugin>

</plugins>
</build>
</project>
9 changes: 0 additions & 9 deletions jcl-over-slf4j/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

16 changes: 16 additions & 0 deletions jul-to-slf4j/pom.xml
Expand Up @@ -31,4 +31,20 @@
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Automatic-Module-Name>$${bsn}</Automatic-Module-Name>
</instructions>
</configuration>
</plugin>

</plugins>
</build>

</project>
8 changes: 0 additions & 8 deletions jul-to-slf4j/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

17 changes: 17 additions & 0 deletions log4j-over-slf4j/pom.xml
Expand Up @@ -41,4 +41,21 @@
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>org.slf4j.*;version="$${range;[===,3);${slf4j.api.minimum.compatible.version}}"</Import-Package>
<Export-Package>org.apache.log4j.*;version=${reload4j.version}</Export-Package>
</instructions>
</configuration>
</plugin>

</plugins>
</build>

</project>
13 changes: 0 additions & 13 deletions log4j-over-slf4j/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

23 changes: 22 additions & 1 deletion osgi-over-slf4j/pom.xml
Expand Up @@ -37,8 +37,29 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-SymbolicName>org.slf4j.osgi-over-slf4j</Bundle-SymbolicName>
<Import-Package>org.slf4j.*;${slf4j_self_import_version},*</Import-Package>
<Export-Package combine.self="override" />
<Bundle-Activator>org.slf4j.osgi.logservice.impl.Activator</Bundle-Activator>
<Bundle-Category>osgi</Bundle-Category>
<Automatic-Module-Name>$${bsn}</Automatic-Module-Name>
</instructions>
</configuration>
</plugin>

</plugins>
</build>

</project>
8 changes: 0 additions & 8 deletions osgi-over-slf4j/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

43 changes: 25 additions & 18 deletions pom.xml
Expand Up @@ -49,6 +49,7 @@
<cal10n.version>0.8.1</cal10n.version>
<reload4j.version>1.2.22</reload4j.version>
<logback.version>1.2.10</logback.version>
<jcl.version>1.2</jcl.version>
<junit.version>4.13.1</junit.version>
<maven-site-plugin.version>3.7.1</maven-site-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
Expand All @@ -59,7 +60,11 @@
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-jxr-plugin.version>3.1.1</maven-jxr-plugin.version>
<maven-bundle-plugin.version>5.1.8</maven-bundle-plugin.version>
<bnd.version>6.4.0</bnd.version>
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>

<project.osgi.version>${version;===;${maven_version;${project.version}}}</project.osgi.version>
<slf4j_self_import_version>version="$${range;[===,3);${project.osgi.version}}"</slf4j_self_import_version>
</properties>

<developers>
Expand Down Expand Up @@ -95,6 +100,12 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bnd.annotation</artifactId>
<version>${bnd.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down Expand Up @@ -238,14 +249,25 @@
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<configuration>
<supportIncrementalBuild>true</supportIncrementalBuild>
<!-- populated by the plugin itself -->
<instructions>
<!-- populated by the plugin itself -->
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
<Bundle-Description>${project.description}</Bundle-Description>
<Bundle-SymbolicName>$${replacestring;${project.artifactId};-;.}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Vendor>SLF4J.ORG</Bundle-Vendor>
<_snapshot />

<Import-Package>org.slf4j.*;${slf4j_self_import_version}</Import-Package>
<Export-Package>!META-INF.*,*</Export-Package>

<Bundle-DocURL>${project.url}</Bundle-DocURL>
<X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
<Implementation-Version>${project.version}</Implementation-Version>
<Implementation-Title>${project.artifactId}</Implementation-Title>
<Multi-Release>true</Multi-Release>

<_removeheaders>Private-Package,Bundle-SCM,Include-Resource</_removeheaders>
</instructions>
</configuration>
<executions>
Expand Down Expand Up @@ -289,21 +311,6 @@
</executions>
</plugin>

<!-- as suggested in http://jira.qos.ch/browse/SLF4J-143 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<executions>
<execution>
<id>parse-version</id>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions slf4j-api/pom.xml
Expand Up @@ -53,6 +53,16 @@
</executions>
</plugin>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>org.slf4j.spi;${slf4j_self_import_version}</Import-Package>
</instructions>
</configuration>
</plugin>

</plugins>

</build>
Expand Down
3 changes: 2 additions & 1 deletion slf4j-api/src/main/java/org/slf4j/LoggerFactory.java
Expand Up @@ -46,7 +46,7 @@
import org.slf4j.helpers.Util;
import org.slf4j.spi.SLF4JServiceProvider;

import javax.accessibility.AccessibleComponent;
import aQute.bnd.annotation.spi.ServiceConsumer;

/**
* The <code>LoggerFactory</code> is a utility class producing Loggers for
Expand All @@ -66,6 +66,7 @@
* @author Ceki G&uuml;lc&uuml;
*
*/
@ServiceConsumer(SLF4JServiceProvider.class)
public final class LoggerFactory {

static final String CODES_PREFIX = "https://www.slf4j.org/codes.html";
Expand Down
15 changes: 0 additions & 15 deletions slf4j-api/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

22 changes: 21 additions & 1 deletion slf4j-ext/pom.xml
Expand Up @@ -73,8 +73,28 @@
</archive>
</configuration>
</plugin>
</plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>
ch.qos.cal10n;version="${cal10n.version}";resolution:="optional",
org.slf4j;${slf4j_self_import_version},
org.slf4j.spi;${slf4j_self_import_version},
org.slf4j.helpers;${slf4j_self_import_version}
</Import-Package>
<Export-Package>
org.slf4j.ext,
org.slf4j.profiler,
org.slf4j.cal10n
</Export-Package>
</instructions>
</configuration>
</plugin>

</plugins>
</build>

</project>
8 changes: 0 additions & 8 deletions slf4j-ext/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

This file was deleted.

Expand Up @@ -7,6 +7,9 @@
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;

import aQute.bnd.annotation.spi.ServiceProvider;

@ServiceProvider(value = SLF4JServiceProvider.class, attribute = { "type=jul" })
public class JULServiceProvider implements SLF4JServiceProvider {

/**
Expand All @@ -30,6 +33,7 @@ public IMarkerFactory getMarkerFactory() {
return markerFactory;
}

@Override
public MDCAdapter getMDCAdapter() {
return mdcAdapter;
}
Expand Down
17 changes: 0 additions & 17 deletions slf4j-jdk14/src/main/resources/META-INF/MANIFEST.MF

This file was deleted.

17 changes: 17 additions & 0 deletions slf4j-migrator/pom.xml
Expand Up @@ -16,4 +16,21 @@
<name>SLF4J Migrator</name>
<description>SLF4J Migrator</description>

<build>
<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>none</phase> <!-- Skip execution -->
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
2 changes: 1 addition & 1 deletion slf4j-migrator/src/main/resources/META-INF/MANIFEST.MF
@@ -1 +1 @@
Main-Class: org.slf4j.migrator.Main
Main-Class: org.slf4j.migrator.Main

0 comments on commit e10feb8

Please sign in to comment.