poom-kitti commented on PR #18018:
URL: https://github.com/apache/kafka/pull/18018#issuecomment-2639311771

   @dejan2609 I would like to think this is directly related to your MR because 
the runtime dependencies are not found, but just to be sure, I will explain how 
I tested it out.
   
   ## Testing out runtime dependencies
   So these are the steps I took after forking your repo
   1. Build to Maven local and specify version as `4.1.0-SNAPSHOT-test`
   ```sh
   gradle :clients:publishToMavenLocal -PskipSigning=true
   ```
   
   2. Ensure the files are created like you have posted before
   ```
   ❯ ls -l  ~/.m2/repository/org/apache/kafka/kafka-clients/4.1.0-SNAPSHOT-test 
   
   -rw-r--r--  1 pkittisrisaw  staff  2675485 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test-javadoc.jar
   -rw-r--r--  1 pkittisrisaw  staff  3777356 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test-sources.jar
   -rw-r--r--  1 pkittisrisaw  staff  1344312 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test-test-sources.jar
   -rw-r--r--  1 pkittisrisaw  staff  2651152 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test-test.jar
   -rw-r--r--  1 pkittisrisaw  staff  9605170 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test.jar
   -rw-r--r--@ 1 pkittisrisaw  staff     1116 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test.module
   -rw-r--r--  1 pkittisrisaw  staff     1785 Feb  6 16:11 
kafka-clients-4.1.0-SNAPSHOT-test.pom
   ```
   
   This is the content of the `kafka-clients-4.1.0-SNAPSHOT-test.module`
   ```
   ❯ cat 
~/.m2/repository/org/apache/kafka/kafka-clients/4.1.0-SNAPSHOT-test/kafka-clients-4.1.0-SNAPSHOT-test.module
 
                  
   {
     "formatVersion": "1.1",
     "component": {
       "group": "org.apache.kafka",
       "module": "kafka-clients",
       "version": "4.1.0-SNAPSHOT-test",
       "attributes": {
         "org.gradle.status": "release"
       }
     },
     "createdBy": {
       "gradle": {
         "version": "8.10.2"
       }
     },
     "variants": [
       {
         "name": "shadowRuntimeElements",
         "attributes": {
           "org.gradle.category": "library",
           "org.gradle.dependency.bundling": "shadowed",
           "org.gradle.libraryelements": "jar",
           "org.gradle.usage": "java-runtime"
         },
         "files": [
           {
             "name": "kafka-clients-4.1.0-SNAPSHOT-test.jar",
             "url": "kafka-clients-4.1.0-SNAPSHOT-test.jar",
             "size": 9605170,
             "sha512": 
"92212b8f530381d7f39edcef5cc1c8e8c92ef8e166bb52af5b0148ebe56233ae3aba9f3b5a24cd1ac893bdcd33331764bf691813e95de387a98821910cbf5a73",
             "sha256": 
"d7687bb2ad6f7231c4c792bace955d4a7b0420e8d78cf4176b5471b2568636b6",
             "sha1": "34567fc759dd2142067bd3f9d535ef554127534c",
             "md5": "33efa7f6713026cad004bfada772a7ac"
           }
         ]
       }
     ]
   }
   ```
   
   3. Create a brand new Gradle Java project (I just use template from 
Intellij) where my Gradle version is 8.10 (irrelevant). This is the content of 
my `build.gradle.kts`
   ```
   plugins {
       id("java")
   }
   
   group = "com.example"
   version = "1.0-SNAPSHOT"
   
   repositories {
       mavenCentral()
       mavenLocal()
   }
   
   dependencies {
       implementation("org.apache.kafka:kafka-clients:4.1.0-SNAPSHOT-test")
   
       testImplementation(platform("org.junit:junit-bom:5.10.0"))
       testImplementation("org.junit.jupiter:junit-jupiter")
   }
   
   tasks.test {
       useJUnitPlatform()
   }
   ```
   
   4. We can check dependencies by running `gradle dependencies` in the 
`runtimeClasspath` section I cannot see the runtime dependencies needed
   ```
   runtimeClasspath - Runtime classpath of source set 'main'.
   \--- org.apache.kafka:kafka-clients:4.1.0-SNAPSHOT-test
   ```
   
   ## Testing removing Gradle module metadata
   1. I have follow the [Gradle 
guide](https://docs.gradle.org/8.10.2/userguide/publishing_gradle_module_metadata.html#sub:disabling-gmm-publication)
 and disable by using
   ```
   tasks.withType(GenerateModuleMetadata) {
       enabled = false
   }
   ``` 
   
   2. I build to Maven Local again with version 
`4.1.0-SNAPSHOT-test-no-gradle-module`. The content are shown below, please 
notice we do not have `.module` file anymore
   ```
   ❯ ls -l  
~/.m2/repository/org/apache/kafka/kafka-clients/4.1.0-SNAPSHOT-test-no-gradle-module
 
   
   -rw-r--r--  1 pkittisrisaw  staff  2682848 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module-javadoc.jar
   -rw-r--r--  1 pkittisrisaw  staff  3777356 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module-sources.jar
   -rw-r--r--  1 pkittisrisaw  staff  1344312 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module-test-sources.jar
   -rw-r--r--  1 pkittisrisaw  staff  2651152 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module-test.jar
   -rw-r--r--  1 pkittisrisaw  staff  9605187 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module.jar
   -rw-r--r--  1 pkittisrisaw  staff     1445 Feb  6 16:15 
kafka-clients-4.1.0-SNAPSHOT-test-no-gradle-module.pom
   ```
   
   Also there is no longer the following comment in the POM file
   ```
     <!-- This module was also published with a richer model, Gradle metadata,  
-->
     <!-- which should be used instead. Do not delete the following line which  
-->
     <!-- is to indicate to Gradle or any Gradle module metadata file consumer  
-->
     <!-- that they should prefer consuming it instead. -->
     <!-- do_not_remove: published-with-gradle-metadata -->
   ```
   
   3. Change to my created Gradle project then modify the dependency to
   ```
   
implementation("org.apache.kafka:kafka-clients:4.1.0-SNAPSHOT-test-no-gradle-module")
   ```
   
   4. This is the content of `runtimeClasspath` after running `gradle 
dependencies`
   ```
   runtimeClasspath - Runtime classpath of source set 'main'.
   \--- org.apache.kafka:kafka-clients:4.1.0-SNAPSHOT-test-no-gradle-module
        +--- com.github.luben:zstd-jni:1.5.6-6
        +--- org.lz4:lz4-java:1.8.0
        +--- org.xerial.snappy:snappy-java:1.1.10.5
        \--- org.slf4j:slf4j-api:1.7.36
   ```
   
   ## Conclusion
   Due to the module metadata existing, I would guess Gradle will check that 
instead of POM, so the runtime dependencies are not discoverable as they are 
not declared there.
   
   Please correct me if I am mistaken anywhere though. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to