-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Maven-Runtime] Support slf4j.api version 2 in m2e.maven.runtime
As part of the new SLF4J-2 major version the mechanism to connect the slf4j.api with a logging back-end has been changed from the static-binding mechanism to Java's ServiceLoader mechanism [1]. In order to support slf4j.api-2 a provider for the maven-slf4j-provider (the logging backend provided/used by Maven based on slf4j-simple) is needed. Because maven-slf4j-provider does not provide it itself we have to supply it for m2e.maven.runtime. [1] - https://www.slf4j.org/faq.html#changesInVersion200
- Loading branch information
1 parent
72edc66
commit 6f08dec
Showing
4 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.classpath | ||
.settings/ | ||
.project | ||
META-INF/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...e.m2e.maven.runtime/src/main/java/org/eclipse/m2e/slf4j2/provider/MavenSLF4JProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023, 2023 Hannes Wellmann and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Hannes Wellmann - initial API and implementation | ||
********************************************************************************/ | ||
|
||
package org.eclipse.m2e.slf4j2.provider; | ||
|
||
import org.slf4j.ILoggerFactory; | ||
import org.slf4j.IMarkerFactory; | ||
import org.slf4j.helpers.BasicMarkerFactory; | ||
import org.slf4j.helpers.NOPMDCAdapter; | ||
import org.slf4j.impl.SimpleLoggerFactory; | ||
import org.slf4j.spi.MDCAdapter; | ||
import org.slf4j.spi.SLF4JServiceProvider; | ||
|
||
public class MavenSLF4JProvider implements SLF4JServiceProvider { | ||
// Based on org.slf4j.simple.SimpleServiceProvider from org.slf4j:slf4j-simple | ||
|
||
private ILoggerFactory loggerFactory; | ||
private final IMarkerFactory markerFactory = new BasicMarkerFactory(); | ||
private final MDCAdapter mdcAdapter = new NOPMDCAdapter(); | ||
|
||
@Override | ||
public ILoggerFactory getLoggerFactory() { | ||
return loggerFactory; | ||
} | ||
|
||
@Override | ||
public IMarkerFactory getMarkerFactory() { | ||
return markerFactory; | ||
} | ||
|
||
@Override | ||
public MDCAdapter getMDCAdapter() { | ||
return mdcAdapter; | ||
} | ||
|
||
@Override | ||
public String getRequestedApiVersion() { | ||
// Declare the version of the maximum SLF4J API this implementation is | ||
// compatible with. The value of this field is modified with each major release. | ||
return "2.0.99"; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
loggerFactory = new SimpleLoggerFactory(); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...m2e.maven.runtime/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.eclipse.m2e.slf4j2.provider.MavenSLF4JProvider |