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

chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5463b69d612 KAFKA-20553 Eliminate the dependencies on 
"sourceSets.test.output" (Server-common)  (#22229)
5463b69d612 is described below

commit 5463b69d612e6386314475d455e714bd1a1c5a31
Author: Ken Huang <[email protected]>
AuthorDate: Sat May 9 13:21:55 2026 +0800

    KAFKA-20553 Eliminate the dependencies on "sourceSets.test.output" 
(Server-common)  (#22229)
    
    Gradle test fixtures to the clients module and removes all dependencies
    on sourceSets.test.output. We should revisit other usages in this JIRA.
    This will simplify the dependency graph and unblock the upgrade to
    Gradle 9.5+
    
    This patch is working on server-common module
    
    Reviewers: Chia-Ping Tsai <[email protected]>
---
 build.gradle                                       | 51 +++++++++++++---------
 .../apache/kafka/server/IntegrationTestUtils.java  |  0
 .../server/common/MetadataVersionTestUtils.java    |  0
 .../kafka/server/fault/MockFaultHandler.java       |  0
 .../kafka/server/immutable/DelegationChecker.java  |  0
 .../org/apache/kafka/server/util/MockRandom.java   |  0
 .../apache/kafka/server/util/MockScheduler.java    |  0
 .../org/apache/kafka/server/util/MockTime.java     |  0
 .../apache/kafka/server/util/ServerTestUtils.java  |  0
 .../apache/kafka/server/util/timer/MockTimer.java  |  0
 .../kafka/timeline/TrackingSnapshotRegistry.java   |  0
 11 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/build.gradle b/build.gradle
index c047c521e94..29bcc6a5ce7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1025,7 +1025,7 @@ project(':server') {
     testImplementation project(':test-common:test-common-internal-api')
     testImplementation project(':test-common:test-common-runtime')
     testImplementation project(':storage:storage-api').sourceSets.test.output
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
 
     testRuntimeOnly runtimeTestLibs
   }
@@ -1143,7 +1143,7 @@ project(':core') {
     testImplementation project(':share-coordinator').sourceSets.test.output
     testImplementation project(':metadata').sourceSets.test.output
     testImplementation project(':raft').sourceSets.test.output
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':storage:storage-api').sourceSets.test.output
     testImplementation project(':server').sourceSets.test.output
     testImplementation project(':streams')
@@ -1418,7 +1418,7 @@ project(':metadata') {
     testImplementation libs.mockitoCore
     testImplementation testFixtures(project(':clients'))
     testImplementation project(':raft').sourceSets.test.output
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':test-common:test-common-util')
 
     testRuntimeOnly runtimeTestLibs
@@ -1540,7 +1540,7 @@ project(':group-coordinator') {
     implementation libs.hash4j
 
     testImplementation testFixtures(project(':clients'))
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':coordinator-common').sourceSets.test.output
     testImplementation libs.jacksonDataformatYaml
     testImplementation libs.junitJupiter
@@ -1769,7 +1769,7 @@ project(':coordinator-common') {
     implementation libs.hdrHistogram
 
     testImplementation testFixtures(project(':clients'))
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation libs.junitJupiter
     testImplementation libs.mockitoCore
     testImplementation testLog4j2Libs
@@ -1805,7 +1805,7 @@ project(':share-coordinator') {
     implementation libs.slf4jApi
 
     testImplementation testFixtures(project(':clients'))
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':coordinator-common').sourceSets.test.output
     testImplementation libs.junitJupiter
     testImplementation libs.mockitoCore
@@ -2128,7 +2128,7 @@ project(':clients:clients-integration-tests') {
     testImplementation project(':core').sourceSets.test.output
     testImplementation testFixtures(project(':clients'))
     implementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':metadata')
     implementation project(':group-coordinator')
     implementation project(':group-coordinator:group-coordinator-api')
@@ -2164,7 +2164,7 @@ project(':raft') {
     implementation libs.slf4jApi
 
     testImplementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':clients')
     testImplementation testFixtures(project(':clients'))
     testImplementation libs.jacksonDataformatYaml
@@ -2254,6 +2254,8 @@ project(':server-common') {
     archivesName = "kafka-server-common"
   }
 
+  apply plugin: 'java-test-fixtures'
+
   dependencies {
     api project(':clients')
     implementation libs.metrics
@@ -2262,6 +2264,12 @@ project(':server-common') {
     implementation libs.pcollections
     implementation libs.slf4jApi
 
+    testFixturesImplementation testFixtures(project(':clients'))
+    testFixturesImplementation libs.slf4jApi
+    testFixturesImplementation libs.metrics
+    testFixturesImplementation libs.mockitoCore
+    testFixturesImplementation libs.junitJupiter
+
     testImplementation project(':clients')
     testImplementation testFixtures(project(':clients'))
     testImplementation libs.jacksonDataformatYaml
@@ -2401,7 +2409,7 @@ project(':storage') {
     testImplementation project(':test-common:test-common-util')
     testImplementation project(':server')
     testImplementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':transaction-coordinator')
     testImplementation libs.hamcrest
     testImplementation libs.jacksonDataformatYaml
@@ -2593,7 +2601,7 @@ project(':tools') {
     testImplementation project(':test-common:test-common-internal-api')
     testImplementation project(':test-common:test-common-runtime')
     testImplementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':connect:api')
     testImplementation project(':connect:runtime')
     testImplementation project(':connect:runtime').sourceSets.test.output
@@ -2721,7 +2729,7 @@ project(':shell') {
     testImplementation project(':clients')
     testImplementation project(':core')
     testImplementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation libs.jacksonDataformatYaml
     testImplementation libs.junitJupiter
     testImplementation testLog4j2Libs
@@ -2969,7 +2977,7 @@ project(':streams:integration-tests') {
     testImplementation project(':group-coordinator')
     testImplementation project(':server')
     testImplementation project(':server-common')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
     testImplementation project(':storage')
     testImplementation project(':streams').sourceSets.test.output
     testImplementation project(':streams:streams-scala')
@@ -3495,7 +3503,7 @@ project(':jmh-benchmarks') {
     implementation project(':connect:transforms')
     implementation project(':connect:json')
     implementation testFixtures(project(':clients'))
-    implementation project(':server-common').sourceSets.test.output
+    implementation testFixtures(project(':server-common'))
     implementation project(':server').sourceSets.test.output
     implementation project(':metadata').sourceSets.test.output
 
@@ -3715,7 +3723,7 @@ project(':connect:runtime') {
     testImplementation project(':group-coordinator')
     testImplementation project(':storage')
     testImplementation project(':connect:test-plugins')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
 
     testImplementation libs.jacksonDataformatYaml
     testImplementation libs.junitJupiter
@@ -3834,7 +3842,7 @@ project(':connect:file') {
     testImplementation project(':connect:runtime').sourceSets.test.output
     testImplementation project(':core')
     testImplementation project(':test-common:test-common-runtime')
-    testImplementation project(':server-common').sourceSets.test.output
+    testImplementation testFixtures(project(':server-common'))
 
     testRuntimeOnly runtimeTestLibs
   }
@@ -4058,18 +4066,21 @@ task aggregatedJavadoc(type: Javadoc) {
 }
 
 gradle.projectsEvaluated {
-  // Validate that no module depends on 
`project(':clients').sourceSets.test.output`
+  // Validate that no module depends on test output directly
+  def protectedModules = ['clients', 'server-common']
   allprojects { proj ->
     proj.configurations.all { config ->
       config.dependencies.each { dep ->
         if (dep instanceof FileCollectionDependency) {
           dep.files.files.each { file ->
-            if 
(file.absolutePath.endsWith('/clients/build/classes/java/test')) {
-              throw new GradleException("""
-ERROR: Dependency on :clients test output is not allowed.
+            protectedModules.each { module ->
+              if 
(file.absolutePath.endsWith("/${module}/build/classes/java/test")) {
+                throw new GradleException("""
+ERROR: Dependency on :${module} test output is not allowed.
 Found in project ${proj.path} configuration '${config.name}'.
-Use `testFixtures(project(':clients'))` instead of 
`project(':clients').sourceSets.test.output`
+Use `testFixtures(project(':${module}'))` instead of 
`project(':${module}').sourceSets.test.output`
 """)
+              }
             }
           }
         }
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/IntegrationTestUtils.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/IntegrationTestUtils.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/IntegrationTestUtils.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/IntegrationTestUtils.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/common/MetadataVersionTestUtils.java
 
b/server-common/src/testFixtures/java/org/apache/kafka/server/common/MetadataVersionTestUtils.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/common/MetadataVersionTestUtils.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/common/MetadataVersionTestUtils.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/fault/MockFaultHandler.java
 
b/server-common/src/testFixtures/java/org/apache/kafka/server/fault/MockFaultHandler.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/fault/MockFaultHandler.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/fault/MockFaultHandler.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/immutable/DelegationChecker.java
 
b/server-common/src/testFixtures/java/org/apache/kafka/server/immutable/DelegationChecker.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/immutable/DelegationChecker.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/immutable/DelegationChecker.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/util/MockRandom.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/util/MockRandom.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/util/MockRandom.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/util/MockRandom.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/util/MockScheduler.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/util/MockScheduler.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/util/MockScheduler.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/util/MockScheduler.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/util/MockTime.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/util/MockTime.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/util/MockTime.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/util/MockTime.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/util/ServerTestUtils.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/util/ServerTestUtils.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/util/ServerTestUtils.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/util/ServerTestUtils.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/server/util/timer/MockTimer.java 
b/server-common/src/testFixtures/java/org/apache/kafka/server/util/timer/MockTimer.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/server/util/timer/MockTimer.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/server/util/timer/MockTimer.java
diff --git 
a/server-common/src/test/java/org/apache/kafka/timeline/TrackingSnapshotRegistry.java
 
b/server-common/src/testFixtures/java/org/apache/kafka/timeline/TrackingSnapshotRegistry.java
similarity index 100%
rename from 
server-common/src/test/java/org/apache/kafka/timeline/TrackingSnapshotRegistry.java
rename to 
server-common/src/testFixtures/java/org/apache/kafka/timeline/TrackingSnapshotRegistry.java

Reply via email to