This is an automated email from the ASF dual-hosted git repository. chia7712 pushed a commit to branch 4.0 in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/4.0 by this push: new 69559950194 KAFKA-18466 Remove log4j-1.2-api from runtime scope while keeping it in distribution package (#18472) 69559950194 is described below commit 69559950194eb630cb60b4e5d4b451bfb14a0d47 Author: TengYao Chi <kiting...@gmail.com> AuthorDate: Sun Jan 12 20:15:10 2025 +0800 KAFKA-18466 Remove log4j-1.2-api from runtime scope while keeping it in distribution package (#18472) Reviewers: Chia-Ping Tsai <chia7...@gmail.com> --- build.gradle | 212 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 101 insertions(+), 111 deletions(-) diff --git a/build.gradle b/build.gradle index daa8b7327d0..d5e635e430c 100644 --- a/build.gradle +++ b/build.gradle @@ -143,11 +143,17 @@ ext { ] log4jRuntimeLibs = [ + libs.slf4jLog4j2, libs.log4j1Bridge2Api, libs.jacksonDatabindYaml ] - log4jLibs = [ + log4j2Libs = [ + libs.log4j2Api, + libs.log4j2Core + ] + + testLog4j2Libs = [ libs.slf4jApi, libs.slf4jLog4j2, libs.log4j2Api, @@ -188,11 +194,7 @@ allprojects { // ensure we have a single version in the classpath despite transitive dependencies libs.scalaLibrary, libs.scalaReflect, - libs.jacksonAnnotations, - libs.jacksonDatabindYaml, - libs.log4j2Api, - libs.log4j2Core, - libs.log4j1Bridge2Api + libs.jacksonAnnotations ) } } @@ -974,14 +976,13 @@ project(':server') { implementation project(':raft') implementation libs.jacksonDatabind implementation libs.metrics - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation libs.mockitoCore testImplementation libs.junitJupiter + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1032,15 +1033,14 @@ project(':share') { dependencies { implementation project(':server-common') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation project(':server-common').sourceSets.test.output testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1071,12 +1071,29 @@ project(':core') { archivesName = "kafka_${versions.baseScala}" } + configurations { + // manually excludes some unnecessary dependencies + implementation.exclude module: 'javax' + implementation.exclude module: 'jline' + implementation.exclude module: 'jms' + implementation.exclude module: 'jmxri' + implementation.exclude module: 'jmxtools' + implementation.exclude module: 'mail' + // To prevent a UniqueResourceException due the same resource existing in both + // org.apache.directory.api/api-all and org.apache.directory.api/api-ldap-schema-data + testImplementation.exclude module: 'api-ldap-schema-data' + releaseOnly + } + dependencies { + releaseOnly log4jRuntimeLibs // `core` is often used in users' tests, define the following dependencies as `api` for backwards compatibility // even though the `core` module doesn't expose any public API api project(':clients') api libs.scalaLibrary + compileOnly log4j2Libs + implementation project(':server-common') implementation project(':group-coordinator:group-coordinator-api') implementation project(':group-coordinator') @@ -1103,9 +1120,7 @@ project(':core') { // only needed transitively, but set it explicitly to ensure it has the same version as scala-library implementation libs.scalaReflect implementation libs.scalaLogging - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation project(':group-coordinator').sourceSets.test.output @@ -1136,6 +1151,7 @@ project(':core') { testImplementation libs.apachedsJdbmPartition testImplementation libs.junitJupiter testImplementation libs.caffeine + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1152,23 +1168,11 @@ project(':core') { } } - configurations { - // manually excludes some unnecessary dependencies - implementation.exclude module: 'javax' - implementation.exclude module: 'jline' - implementation.exclude module: 'jms' - implementation.exclude module: 'jmxri' - implementation.exclude module: 'jmxtools' - implementation.exclude module: 'mail' - // To prevent a UniqueResourceException due the same resource existing in both - // org.apache.directory.api/api-all and org.apache.directory.api/api-ldap-schema-data - testImplementation.exclude module: 'api-ldap-schema-data' - } - tasks.create(name: "copyDependantLibs", type: Copy) { from (configurations.runtimeClasspath) { exclude('kafka-clients*') } + from (configurations.releaseOnly) into "$buildDir/dependant-libs-${versions.scala}" duplicatesStrategy 'exclude' } @@ -1278,6 +1282,7 @@ project(':core') { from "$rootDir/NOTICE-binary" rename {String filename -> filename.replace("-binary", "")} from(configurations.runtimeClasspath) { into("libs/") } from(configurations.archives.artifacts.files) { into("libs/") } + from(configurations.releaseOnly) { into("libs/") } from(project.siteDocsTar) { into("site-docs/") } from(project(':tools').jar) { into("libs/") } from(project(':tools').configurations.runtimeClasspath) { into("libs/") } @@ -1378,10 +1383,9 @@ project(':metadata') { implementation libs.jacksonDatabind implementation libs.jacksonJDK8Datatypes implementation libs.metrics - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi + testImplementation testLog4j2Libs testImplementation libs.junitJupiter testImplementation libs.jqwik testImplementation libs.mockitoCore @@ -1504,9 +1508,7 @@ project(':group-coordinator') { implementation libs.metrics implementation libs.hdrHistogram implementation libs.re2j - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation project(':server-common').sourceSets.test.output @@ -1514,6 +1516,7 @@ project(':group-coordinator') { testImplementation libs.jacksonDatabindYaml testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs @@ -1574,12 +1577,11 @@ project(':test-common') { implementation project(':storage') implementation project(':server-common') implementation libs.jacksonDatabindYaml - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1613,6 +1615,7 @@ project(':test-common:test-common-api') { testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1636,9 +1639,8 @@ project(':test-common:test-common-runtime') { implementation libs.junitPlatformLanucher implementation libs.junitJupiterApi implementation libs.junitJupiter - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi + testImplementation testLog4j2Libs } checkstyle { @@ -1663,10 +1665,9 @@ project(':transaction-coordinator') { implementation libs.jacksonDatabind implementation project(':clients') implementation project(':server-common') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi + testImplementation testLog4j2Libs testImplementation libs.junitJupiter testImplementation libs.mockitoCore testImplementation project(':clients').sourceSets.test.output @@ -1728,16 +1729,15 @@ project(':coordinator-common') { implementation project(':server-common') implementation project(':metadata') implementation project(':storage') - implementation log4jLibs + implementation libs.slf4jApi implementation libs.metrics implementation libs.hdrHistogram - runtimeOnly log4jRuntimeLibs - testImplementation project(':clients').sourceSets.test.output testImplementation project(':server-common').sourceSets.test.output testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -1769,15 +1769,14 @@ project(':share-coordinator') { implementation project(':server-common') implementation project(':share') implementation libs.metrics - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation project(':server-common').sourceSets.test.output testImplementation project(':coordinator-common').sourceSets.test.output testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs @@ -1901,7 +1900,7 @@ project(':clients') { testImplementation libs.spotbugs testImplementation libs.mockitoCore testImplementation libs.mockitoJunitJupiter // supports MockitoExtension - testImplementation log4jLibs + testImplementation testLog4j2Libs testCompileOnly libs.bndlib @@ -2062,9 +2061,7 @@ project(':raft') { implementation project(':server-common') implementation project(':clients') implementation libs.jacksonDatabind - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':server-common') testImplementation project(':server-common').sourceSets.test.output @@ -2074,6 +2071,7 @@ project(':raft') { testImplementation libs.junitJupiter testImplementation libs.mockitoCore testImplementation libs.jqwik + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs @@ -2162,15 +2160,14 @@ project(':server-common') { implementation libs.joptSimple implementation libs.jacksonDatabind implementation libs.pcollections - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients') testImplementation project(':clients').sourceSets.test.output testImplementation libs.jacksonDatabindYaml testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -2223,14 +2220,13 @@ project(':storage:storage-api') { implementation project(':clients') implementation project(':server-common') implementation libs.metrics - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients') testImplementation project(':clients').sourceSets.test.output testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -2291,12 +2287,10 @@ project(':storage') { implementation(libs.caffeine) { exclude group: 'org.checkerframework', module: 'checker-qual' } - implementation log4jLibs + implementation libs.slf4jApi implementation libs.jacksonDatabind implementation libs.metrics - runtimeOnly log4jRuntimeLibs - testImplementation project(':clients') testImplementation project(':clients').sourceSets.test.output testImplementation project(':core') @@ -2310,6 +2304,7 @@ project(':storage') { testImplementation libs.junitJupiter testImplementation libs.mockitoCore testImplementation libs.bcpkix + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs @@ -2408,6 +2403,7 @@ project(':tools:tools-api') { dependencies { implementation project(':clients') testImplementation libs.junitJupiter + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -2451,7 +2447,13 @@ project(':tools') { archivesName = "kafka-tools" } + configurations { + releaseOnly + } + dependencies { + releaseOnly log4jRuntimeLibs + implementation project(':clients') implementation project(':metadata') implementation project(':storage') @@ -2469,14 +2471,12 @@ project(':tools') { implementation libs.jacksonDataformatCsv implementation libs.jacksonJDK8Datatypes implementation libs.joptSimple - implementation log4jLibs + implementation libs.slf4jApi implementation libs.re2j implementation libs.jose4j // for SASL/OAUTHBEARER JWT validation implementation libs.jacksonJakartarsJsonProvider - runtimeOnly log4jRuntimeLibs - compileOnly libs.spotbugs testImplementation project(':clients') @@ -2510,6 +2510,7 @@ project(':tools') { testImplementation libs.apachedsProtocolKerberos testImplementation libs.apachedsProtocolLdap testImplementation libs.apachedsLdifPartition + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs testRuntimeOnly libs.hamcrest @@ -2523,6 +2524,7 @@ project(':tools') { from (configurations.runtimeClasspath) { exclude('kafka-clients*') } + from (configurations.releaseOnly) into "$buildDir/dependant-libs-${versions.scala}" duplicatesStrategy 'exclude' } @@ -2542,7 +2544,7 @@ project(':trogdor') { implementation libs.argparse4j implementation libs.jacksonDatabind implementation libs.jacksonJDK8Datatypes - implementation log4jLibs + implementation libs.slf4jApi implementation libs.jacksonJakartarsJsonProvider implementation libs.jerseyContainerServlet @@ -2562,13 +2564,12 @@ project(':trogdor') { implementation project(':group-coordinator') implementation project(':group-coordinator:group-coordinator-api') - runtimeOnly log4jRuntimeLibs - testImplementation project(':clients') testImplementation project(':clients').sourceSets.test.output testImplementation project(':group-coordinator') testImplementation libs.junitJupiter testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs testRuntimeOnly libs.junitPlatformLanucher @@ -2601,7 +2602,7 @@ project(':shell') { implementation libs.jacksonDatabind implementation libs.jacksonJDK8Datatypes implementation libs.jline - implementation log4jLibs + implementation libs.slf4jApi implementation project(':server-common') implementation project(':clients') implementation project(':core') @@ -2611,8 +2612,6 @@ project(':shell') { implementation libs.jose4j // for SASL/OAUTHBEARER JWT validation implementation libs.jacksonJakartarsJsonProvider - runtimeOnly log4jRuntimeLibs - testImplementation project(':clients') testImplementation project(':clients').sourceSets.test.output testImplementation project(':core') @@ -2620,6 +2619,7 @@ project(':shell') { testImplementation project(':server-common').sourceSets.test.output testImplementation libs.jacksonDatabindYaml testImplementation libs.junitJupiter + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -2673,7 +2673,7 @@ project(':streams') { testImplementation libs.mockitoCore testImplementation libs.mockitoJunitJupiter // supports MockitoExtension testImplementation libs.junitPlatformSuiteEngine // supports suite test - testImplementation log4jLibs + testImplementation testLog4j2Libs testRuntimeOnly project(':streams:test-utils') testRuntimeOnly runtimeTestLibs @@ -2814,6 +2814,8 @@ project(':streams:streams-scala') { testImplementation libs.jacksonDatabindYaml testImplementation libs.junitJupiter testImplementation libs.mockitoJunitJupiter // supports MockitoExtension + testImplementation testLog4j2Libs + testRuntimeOnly runtimeTestLibs } @@ -2855,9 +2857,7 @@ project(':streams:integration-tests') { } dependencies { - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation project(':group-coordinator') @@ -2875,6 +2875,7 @@ project(':streams:integration-tests') { testImplementation libs.junitJupiter testImplementation libs.junitPlatformSuiteEngine // supports suite test testImplementation libs.mockitoCore + testImplementation testLog4j2Libs testImplementation project(':streams:test-utils') testRuntimeOnly runtimeTestLibs @@ -2910,15 +2911,14 @@ project(':streams:test-utils') { api project(':streams') api project(':clients') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':clients').sourceSets.test.output testImplementation libs.jacksonDatabindYaml testImplementation libs.junitJupiter testImplementation libs.mockitoCore testImplementation libs.hamcrest + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -2946,14 +2946,13 @@ project(':streams:examples') { // this dependency should be removed after we unify data API implementation(project(':connect:json')) implementation project(':streams') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation project(':streams:test-utils') testImplementation project(':clients').sourceSets.test.output // for org.apache.kafka.test.IntegrationTest testImplementation libs.junitJupiter testImplementation libs.hamcrest + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -3344,9 +3343,7 @@ project(':jmh-benchmarks') { implementation libs.metrics implementation libs.mockitoCore implementation libs.scalaLibrary - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi } tasks.withType(JavaCompile) { @@ -3389,12 +3386,11 @@ project(':connect:api') { dependencies { api project(':clients') implementation libs.jakartaRsApi - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation libs.junitJupiter testImplementation project(':clients').sourceSets.test.output + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -3425,12 +3421,11 @@ project(':connect:transforms') { dependencies { api project(':connect:api') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation libs.junitJupiter testImplementation project(':clients').sourceSets.test.output + testImplementation testLog4j2Libs testRuntimeOnly runtimeTestLibs } @@ -3465,12 +3460,10 @@ project(':connect:json') { api libs.jacksonJDK8Datatypes api libs.jacksonBlackbird - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi testImplementation libs.junitJupiter - + testImplementation testLog4j2Libs testImplementation project(':clients').sourceSets.test.output testRuntimeOnly runtimeTestLibs @@ -3511,7 +3504,9 @@ project(':connect:runtime') { api project(':connect:json') api project(':connect:transforms') - implementation log4jLibs + compileOnly log4j2Libs + + implementation libs.slf4jApi implementation libs.jose4j // for SASL/OAUTHBEARER JWT validation implementation libs.jacksonAnnotations implementation libs.jacksonJakartarsJsonProvider @@ -3538,8 +3533,6 @@ project(':connect:runtime') { compileOnly libs.bndlib compileOnly libs.spotbugs - runtimeOnly log4jRuntimeLibs - // We use this library to generate OpenAPI docs for the REST API, but we don't want or need it at compile // or run time. So, we add it to a separate configuration, which we use later on during docs generation swagger libs.jakartaServletApi @@ -3564,6 +3557,7 @@ project(':connect:runtime') { testImplementation libs.mockitoCore testImplementation libs.mockitoJunitJupiter testImplementation libs.httpclient + testImplementation testLog4j2Libs testCompileOnly libs.bndlib @@ -3660,10 +3654,9 @@ project(':connect:file') { dependencies { implementation project(':connect:api') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi + testImplementation testLog4j2Libs testImplementation libs.junitJupiter testImplementation libs.mockitoCore @@ -3703,15 +3696,14 @@ project(':connect:basic-auth-extension') { dependencies { implementation project(':connect:api') - implementation log4jLibs + implementation libs.slf4jApi implementation libs.jakartaRsApi implementation libs.jaxAnnotationApi - runtimeOnly log4jRuntimeLibs - testImplementation libs.bcpkix testImplementation libs.mockitoCore testImplementation libs.junitJupiter + testImplementation testLog4j2Libs testImplementation project(':clients').sourceSets.test.output testRuntimeOnly libs.jerseyContainerServlet @@ -3748,7 +3740,7 @@ project(':connect:mirror') { implementation project(':clients') implementation libs.argparse4j - implementation log4jLibs + implementation libs.slf4jApi implementation libs.jacksonAnnotations implementation libs.jacksonJakartarsJsonProvider implementation libs.jerseyContainerServlet @@ -3769,8 +3761,7 @@ project(':connect:mirror') { } implementation libs.swaggerAnnotations - runtimeOnly log4jRuntimeLibs - + testImplementation testLog4j2Libs testImplementation libs.junitJupiter testImplementation libs.bndlib testImplementation libs.mockitoCore @@ -3840,10 +3831,9 @@ project(':connect:mirror-client') { dependencies { implementation project(':clients') - implementation log4jLibs - - runtimeOnly log4jRuntimeLibs + implementation libs.slf4jApi + testImplementation testLog4j2Libs testImplementation libs.junitJupiter testImplementation project(':clients').sourceSets.test.output @@ -3877,10 +3867,10 @@ project(':connect:test-plugins') { api project(':connect:api') implementation project(':server-common') - implementation log4jLibs + implementation libs.slf4jApi implementation libs.jacksonDatabind - runtimeOnly log4jRuntimeLibs + testImplementation testLog4j2Libs } }