You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2021/12/17 10:05:55 UTC

[sling-org-apache-sling-commons-log] branch master updated: SLING-9528 - Update commons log to parent pom 39 or newer (#8)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-log.git


The following commit(s) were added to refs/heads/master by this push:
     new abd634f  SLING-9528 - Update commons log to parent pom 39 or newer (#8)
abd634f is described below

commit abd634f1c969ed6400bb18c71041dc969b5d60a9
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Dec 17 11:05:16 2021 +0100

    SLING-9528 - Update commons log to parent pom 39 or newer (#8)
    
    Co-authored-by: Carsten Ziegeler <cz...@apache.org>
---
 bnd.bnd                                            |  35 ++++++
 pom.xml                                            | 117 +++------------------
 .../commons/log/logback/internal/Activator.java    |   4 +
 .../logback/integration/ITAppenderServices.java    |  23 ++--
 .../log/logback/integration/LogTestBase.java       |  20 ++--
 .../internal/util/LoggerSpecificEncoderTest.java   |  29 ++---
 6 files changed, 93 insertions(+), 135 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
new file mode 100644
index 0000000..9760468
--- /dev/null
+++ b/bnd.bnd
@@ -0,0 +1,35 @@
+Bundle-DocURL: http://sling.apache.org/site/logging.html
+Import-Package: !org.slf4j.impl, \
+              !org.osgi.service.cm, \
+              !javax.servlet, \
+              !javax.servlet.http, \
+              !org.osgi.service.event, \
+              !javax.xml.transform, \
+              !javax.xml.transform.sax, \
+              !javax.xml.transform.stream, \
+              org.osgi.framework;version=1.3, \
+              !groovy.lang, \
+              !org.codehaus.*, \
+              !javax.jms, \
+              !javax.mail, \
+              !javax.mail.internet, \
+              javax.management; \
+              javax.naming; \
+              javax.sql; \
+              javax.xml.parsers; \
+              org.xml.sax.*; \
+              sun.reflect;resolution:=optional, \
+              *
+DynamicImport-Package: org.osgi.service.cm;version=1.2, \
+              org.osgi.service.event;version=1.2, \
+              javax.xml.transform, \
+              javax.xml.transform.sax, \
+              javax.xml.transform.stream
+Export-Package: ch.qos.logback.classic*, \
+              ch.qos.logback.core*, \
+              org.slf4j.impl;version=${slf4j.version}, \
+              org.apache.sling.commons.log.logback, \
+              org.apache.sling.commons.log.logback.webconsole
+Conditional-Package: org.slf4j.bridge
+-fixupmessages: 
+
diff --git a/pom.xml b/pom.xml
index 108c4c1..154efd0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,16 +22,15 @@
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.sling</groupId>
-    <artifactId>sling</artifactId>
-    <version>30</version>
+    <artifactId>sling-bundle-parent</artifactId>
+    <version>46</version>
     <relativePath />
   </parent>
 
   <artifactId>org.apache.sling.commons.log</artifactId>
   <version>5.2.1-SNAPSHOT</version>
-  <packaging>bundle</packaging>
 
-    <name>Apache Sling Commons Log</name>
+  <name>Apache Sling Commons Log</name>
   <description>
     This bundle embeds Logback which provides the SLF4J logging API.
     The embedding supports dynamic OSGi-configuration without
@@ -48,9 +47,10 @@
   <properties>
     <slf4j.version>1.7.32</slf4j.version>
     <logback.version>1.2.8</logback.version>
+    <!-- Higher versions of pax exam cause class loading errors -->
     <pax-exam.version>4.13.2</pax-exam.version>
     <sling.java.version>8</sling.java.version>
-
+    <project.build.outputTimestamp>1</project.build.outputTimestamp>
     <bundle.build.dir>
       ${basedir}/target
     </bundle.build.dir>
@@ -64,12 +64,8 @@
       <plugins>
         <!--
         Unfortunately the <ignores> sections do not seem to
-        properly work, so the sniffer is disabled by default.
-
-        Note: 1.9 contains a call to a Java 7 specific method
-        (java.nio.CharBuffer.subSequence(II)Ljava/nio/CharBuffer;)
-        that is triggered when an undefined reference is found. This breaks error
-        reporting on Java 5/6.
+        properly work, so the sniffer is disabled by default
+        if the project is built with Java 8.
       -->
         <plugin>
           <groupId>org.codehaus.mojo</groupId>
@@ -77,14 +73,6 @@
           <version>1.8</version>
           <configuration>
             <skip>true</skip>
-            <ignores>
-              <ignore>ch.qos.logback.classic.spi*</ignore>
-            </ignores>
-            <signature>
-              <groupId>org.codehaus.mojo.signature</groupId>
-              <artifactId>java1${sling.java.version}</artifactId>
-              <version>1.0</version>
-            </signature>
           </configuration>
         </plugin>
       </plugins>
@@ -92,66 +80,8 @@
 
     <plugins>
       <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Bundle-Activator>
-              org.apache.sling.commons.log.logback.internal.Activator
-            </Bundle-Activator>
-            <Bundle-DocURL>
-              http://sling.apache.org/site/logging.html
-            </Bundle-DocURL>
-            <_exportcontents>
-              org.slf4j.impl;version=${slf4j.version},
-              ch.qos.logback.classic*;
-              ch.qos.logback.core*;
-            </_exportcontents>
-            <Import-Package>
-              !org.slf4j.impl,
-              !org.osgi.service.cm,
-              !javax.servlet,
-              !javax.servlet.http,
-              !org.osgi.service.event,
-              !javax.xml.transform,
-              !javax.xml.transform.sax,
-              !javax.xml.transform.stream,
-              org.osgi.framework;version=1.3,
-              org.slf4j;version="[1.6,1.8)",
-              org.slf4j.spi;version="[1.6,1.8)",
-              !groovy.lang,
-              !org.codehaus.*,
-              !javax.jms,
-              !javax.mail,
-              !javax.mail.internet,
-              javax.management;
-              javax.naming;
-              javax.sql;
-              javax.xml.parsers;
-              org.xml.sax.*;
-              sun.reflect;resolution:=optional,
-              *
-            </Import-Package>
-            <Export-Package>
-              org.apache.sling.commons.log.logback,
-              org.apache.sling.commons.log.logback.webconsole
-            </Export-Package>
-            <DynamicImport-Package>
-              org.osgi.service.cm;version=1.2,
-              org.osgi.service.event;version=1.2,
-              <!-- Required by WebConsole support-->
-              javax.xml.transform,
-              javax.xml.transform.sax,
-              javax.xml.transform.stream
-            </DynamicImport-Package>
-            <Embed-Dependency>
-              jul-to-slf4j;inline="org/slf4j/bridge/SLF4JBridgeHandler.class",
-              logback-core,
-              logback-classic
-            </Embed-Dependency>
-          </instructions>
-        </configuration>
+        <groupId>biz.aQute.bnd</groupId>
+        <artifactId>bnd-maven-plugin</artifactId>
       </plugin>
       <!-- Required for pax exam-->
       <plugin>
@@ -265,20 +195,20 @@
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>osgi.core</artifactId>
-      <version>6.0.0</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>osgi.cmpn</artifactId>
-      <version>6.0.0</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.annotation</artifactId>
-      <scope>provided</scope>
-      <version>6.0.0</version>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.annotation.versioning</artifactId>
+    </dependency>
+    <dependency>
+        <groupId>org.osgi</groupId>
+        <artifactId>org.osgi.annotation.bundle</artifactId>
     </dependency>
 
     <!--  OSGi Command Line Shell support -->
@@ -298,7 +228,7 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
-      <version>5.6.2</version>
+      <version>7.0.1</version>
       <scope>test</scope>
     </dependency>
 
@@ -328,18 +258,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>biz.aQute.bnd</groupId>
-      <artifactId>biz.aQute.bndlib</artifactId>
-      <version>3.5.0</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>org.osgi</groupId>
-          <artifactId>org.osgi.core</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
         <groupId>org.osgi</groupId>
         <artifactId>org.osgi.service.log</artifactId>
         <version>1.3.0</version>
@@ -348,7 +266,6 @@
     <dependency>
       <groupId>javax.inject</groupId>
       <artifactId>javax.inject</artifactId>
-      <version>1</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -373,7 +290,7 @@
     <dependency>
       <groupId>org.ops4j.pax.url</groupId>
       <artifactId>pax-url-wrap</artifactId>
-      <version>2.1.0</version>
+      <version>2.6.10</version>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/src/main/java/org/apache/sling/commons/log/logback/internal/Activator.java b/src/main/java/org/apache/sling/commons/log/logback/internal/Activator.java
index ebaff94..ef89442 100644
--- a/src/main/java/org/apache/sling/commons/log/logback/internal/Activator.java
+++ b/src/main/java/org/apache/sling/commons/log/logback/internal/Activator.java
@@ -26,12 +26,16 @@ import java.util.concurrent.atomic.AtomicInteger;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.util.StatusPrinter;
+
+import org.osgi.annotation.bundle.Header;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
 public class Activator implements BundleActivator {
 
     private LogbackManager logManager;
diff --git a/src/test/java/org/apache/sling/commons/log/logback/integration/ITAppenderServices.java b/src/test/java/org/apache/sling/commons/log/logback/integration/ITAppenderServices.java
index 7762664..539461c 100644
--- a/src/test/java/org/apache/sling/commons/log/logback/integration/ITAppenderServices.java
+++ b/src/test/java/org/apache/sling/commons/log/logback/integration/ITAppenderServices.java
@@ -19,6 +19,13 @@
 
 package org.apache.sling.commons.log.logback.integration;
 
+import static org.apache.sling.commons.log.logback.integration.ITConfigFragments.RESET_EVENT_TOPIC;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -26,11 +33,6 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.AppenderBase;
 import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -46,12 +48,11 @@ import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.sling.commons.log.logback.integration.ITConfigFragments.RESET_EVENT_TOPIC;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.composite;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.Appender;
+import ch.qos.logback.core.AppenderBase;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
diff --git a/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java b/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java
index 239ae6b..4bf6eb1 100644
--- a/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java
+++ b/src/test/java/org/apache/sling/commons/log/logback/integration/LogTestBase.java
@@ -19,6 +19,16 @@
 
 package org.apache.sling.commons.log.logback.integration;
 
+import static org.ops4j.pax.exam.CoreOptions.composite;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.keepCaches;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.systemTimeout;
+import static org.ops4j.pax.exam.CoreOptions.workingDirectory;
+import static org.ops4j.pax.exam.util.PathUtils.getBaseDir;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
@@ -33,16 +43,6 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
 import org.osgi.framework.BundleContext;
 
-import static org.ops4j.pax.exam.CoreOptions.composite;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.keepCaches;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.systemTimeout;
-import static org.ops4j.pax.exam.CoreOptions.workingDirectory;
-import static org.ops4j.pax.exam.util.PathUtils.getBaseDir;
-
 public abstract class LogTestBase {
     @Inject
     protected BundleContext bundleContext;
diff --git a/src/test/java/org/apache/sling/commons/log/logback/internal/util/LoggerSpecificEncoderTest.java b/src/test/java/org/apache/sling/commons/log/logback/internal/util/LoggerSpecificEncoderTest.java
index a32e406..d267f3b 100644
--- a/src/test/java/org/apache/sling/commons/log/logback/internal/util/LoggerSpecificEncoderTest.java
+++ b/src/test/java/org/apache/sling/commons/log/logback/internal/util/LoggerSpecificEncoderTest.java
@@ -19,9 +19,15 @@
 
 package org.apache.sling.commons.log.logback.internal.util;
 
-import ch.qos.logback.classic.PatternLayout;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import org.apache.felix.framework.util.ImmutableList;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
 import org.apache.sling.commons.log.logback.internal.LogConfig;
 import org.junit.Before;
 import org.junit.Test;
@@ -29,13 +35,8 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
-import java.util.HashSet;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.classic.spi.ILoggingEvent;
 
 @RunWith(MockitoJUnitRunner.class)
 public class LoggerSpecificEncoderTest {
@@ -60,7 +61,7 @@ public class LoggerSpecificEncoderTest {
     @Test
     public void testShouldIgnoreNonmatchingLayoutCategories() {
         LogConfig logConfigMock = mock(LogConfig.class);
-        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(ImmutableList.newInstance("org.apache.commons", "com.initech.sling")));
+        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(Arrays.asList("org.apache.commons", "com.initech.sling")));
         when(logConfigMock.createLayout()).thenReturn(new PrefixTestLayout("INITECH:"));
         tested.addLogConfig(logConfigMock);
 
@@ -70,7 +71,7 @@ public class LoggerSpecificEncoderTest {
     @Test
     public void testShouldIgnorePartialMatchingPackageName() {
         LogConfig logConfigMock = mock(LogConfig.class);
-        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(ImmutableList.newInstance("org.apache.sling.test")));
+        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(Arrays.asList("org.apache.sling.test")));
         when(logConfigMock.createLayout()).thenReturn(new PrefixTestLayout("INITECH:"));
         tested.addLogConfig(logConfigMock);
 
@@ -80,7 +81,7 @@ public class LoggerSpecificEncoderTest {
     @Test
     public void testShouldUseExactMatchingCategoryLayout() {
         LogConfig logConfigMock = mock(LogConfig.class);
-        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(ImmutableList.newInstance("org.apache.sling.testing.FooBar")));
+        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(Arrays.asList("org.apache.sling.testing.FooBar")));
         when(logConfigMock.createLayout()).thenReturn(new PrefixTestLayout("INITECH:"));
         tested.addLogConfig(logConfigMock);
 
@@ -90,7 +91,7 @@ public class LoggerSpecificEncoderTest {
     @Test
     public void testShouldUseInheritedCategoryLayout() {
         LogConfig logConfigMock = mock(LogConfig.class);
-        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(ImmutableList.newInstance("org.apache")));
+        when(logConfigMock.getCategories()).thenReturn(new HashSet<>(Arrays.asList("org.apache")));
         when(logConfigMock.createLayout()).thenReturn(new PrefixTestLayout("INITECH:"));
         tested.addLogConfig(logConfigMock);