You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/10/20 14:22:20 UTC

[logging-log4j2] 01/02: Ban dependencies interfering with our tests

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

pkarwasz pushed a commit to branch prerelease/2.21.1
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit f303f2de3a177d38334e444eb78be7383c4d6f82
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Fri Oct 20 16:02:00 2023 +0200

    Ban dependencies interfering with our tests
---
 log4j-cassandra/pom.xml   | 10 -------
 log4j-core-its/pom.xml    | 18 +++++--------
 log4j-core-test/pom.xml   | 17 +++++-------
 log4j-jakarta-web/pom.xml |  7 ++++-
 log4j-osgi-test/pom.xml   | 10 -------
 log4j-parent/pom.xml      | 67 +++++++++++++++++++++++++++++++++++++++++++++++
 log4j-perf-test/pom.xml   | 24 +++++++++++++++--
 log4j-spring-boot/pom.xml |  6 +++++
 log4j-taglib/pom.xml      |  7 ++++-
 log4j-to-slf4j/pom.xml    | 26 ++++++++++++++++++
 log4j-web/pom.xml         |  7 ++++-
 11 files changed, 151 insertions(+), 48 deletions(-)

diff --git a/log4j-cassandra/pom.xml b/log4j-cassandra/pom.xml
index 24016c467f..3c0302e547 100644
--- a/log4j-cassandra/pom.xml
+++ b/log4j-cassandra/pom.xml
@@ -86,16 +86,6 @@
       <groupId>org.apache.cassandra</groupId>
       <artifactId>cassandra-all</artifactId>
       <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-classic</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-core</artifactId>
-        </exclusion>
-      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.cassandra</groupId>
diff --git a/log4j-core-its/pom.xml b/log4j-core-its/pom.xml
index 963cd8ed1d..e594926512 100644
--- a/log4j-core-its/pom.xml
+++ b/log4j-core-its/pom.xml
@@ -153,17 +153,6 @@
       <artifactId>log4j</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <!-- Logback performance tests -->
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-core</artifactId>
-      <scope>test</scope>
-    </dependency>
     <!-- SLF4J tests -->
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -179,7 +168,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
-      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
   <build>
diff --git a/log4j-core-test/pom.xml b/log4j-core-test/pom.xml
index d73a6a6864..89fae5cdfd 100644
--- a/log4j-core-test/pom.xml
+++ b/log4j-core-test/pom.xml
@@ -108,6 +108,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <!-- JNDI and JMS tests -->
     <dependency>
@@ -278,17 +284,6 @@
       <artifactId>kafka-clients</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <!-- Logback performance tests -->
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-core</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
diff --git a/log4j-jakarta-web/pom.xml b/log4j-jakarta-web/pom.xml
index 84c90d9877..5a14417e22 100644
--- a/log4j-jakarta-web/pom.xml
+++ b/log4j-jakarta-web/pom.xml
@@ -82,7 +82,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
-      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index f043135c7e..940e1f2225 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -86,16 +86,6 @@
       <artifactId>junit-vintage-engine</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-classic</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>ch.qos.logback</groupId>
-      <artifactId>logback-core</artifactId>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.framework</artifactId>
diff --git a/log4j-parent/pom.xml b/log4j-parent/pom.xml
index e8ac4647e3..79c547fe74 100644
--- a/log4j-parent/pom.xml
+++ b/log4j-parent/pom.xml
@@ -326,6 +326,24 @@
         <groupId>org.apache.cassandra</groupId>
         <artifactId>cassandra-all</artifactId>
         <version>${cassandra.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <dependency>
@@ -338,6 +356,16 @@
         <groupId>org.apache.cassandra</groupId>
         <artifactId>cassandra-thrift</artifactId>
         <version>${cassandra.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
 
       <dependency>
@@ -1077,6 +1105,45 @@
 
       </plugins>
     </pluginManagement>
+
+    <plugins>
+      <!--
+        ~ Some external logging bridges can interfere with our tests, giving false negatives.
+        -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>ban-logging-dependencies</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <excludes>
+                    <!-- JCL replacements -->
+                    <exclude>org.slf4j:jcl-over-slf4j</exclude>
+                    <exclude>org.springframework:spring-jcl</exclude>
+                    <!-- Log4j 1.x replacements -->
+                    <exclude>org.slf4j:log4j-over-slf4j</exclude>
+                    <exclude>ch.qos.reload4j:reload4j</exclude>
+                    <!-- Bridges to Log4j 1.x -->
+                    <exclude>org.slf4j:slf4j-log4j12</exclude>
+                    <exclude>org.slf4j:slf4j-reload4j</exclude>
+                    <!-- PAX Logging just to be safe -->
+                    <exclude>org.ops4j.pax.logging:*</exclude>
+                    <!-- Logback -->
+                    <exclude>ch.qos.logback:*</exclude>
+                  </excludes>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
   </build>
 
 </project>
diff --git a/log4j-perf-test/pom.xml b/log4j-perf-test/pom.xml
index 200cbe069e..2717fb5a90 100644
--- a/log4j-perf-test/pom.xml
+++ b/log4j-perf-test/pom.xml
@@ -120,12 +120,10 @@
     <dependency>
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-classic</artifactId>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>ch.qos.logback</groupId>
       <artifactId>logback-core</artifactId>
-      <scope>compile</scope>
     </dependency>
     <dependency>
       <groupId>org.eclipse.persistence</groupId>
@@ -144,6 +142,28 @@
   <build>
     <plugins>
 
+      <!--
+        ~ Unban Logback.
+        -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>ban-logging-dependencies</id>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <includes>
+                    <include>ch.qos.logback:*</include>
+                  </includes>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
diff --git a/log4j-spring-boot/pom.xml b/log4j-spring-boot/pom.xml
index ca58823008..bc787a8bad 100644
--- a/log4j-spring-boot/pom.xml
+++ b/log4j-spring-boot/pom.xml
@@ -54,6 +54,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-core</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.springframework</groupId>
diff --git a/log4j-taglib/pom.xml b/log4j-taglib/pom.xml
index 509338bad3..27efe28819 100644
--- a/log4j-taglib/pom.xml
+++ b/log4j-taglib/pom.xml
@@ -84,7 +84,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
-      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
 </project>
diff --git a/log4j-to-slf4j/pom.xml b/log4j-to-slf4j/pom.xml
index 2ea30e826e..cf5de792ce 100644
--- a/log4j-to-slf4j/pom.xml
+++ b/log4j-to-slf4j/pom.xml
@@ -96,4 +96,30 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <!--
+        ~ Unban Logback.
+        -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>ban-logging-dependencies</id>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <includes>
+                    <include>ch.qos.logback:*:*:*:test</include>
+                  </includes>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/log4j-web/pom.xml b/log4j-web/pom.xml
index 9a7f00c906..331bb0462f 100644
--- a/log4j-web/pom.xml
+++ b/log4j-web/pom.xml
@@ -86,7 +86,12 @@
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
-      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>org.springframework</groupId>
+          <artifactId>spring-jcl</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>