Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-16359: Corrected manifest file for kafka-clients #15532

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 26 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,24 @@ subprojects {
} else {
apply plugin: 'com.github.johnrengelman.shadow'
project.shadow.component(mavenJava)

// Fix for avoiding inclusion of runtime dependencies marked as 'shadow' in MANIFEST Class-Path.
// https://github.com/johnrengelman/shadow/issues/324
afterEvaluate {
pom.withXml { xml ->
if (xml.asNode().get('dependencies') == null) {
xml.asNode().appendNode('dependencies')
}
def dependenciesNode = xml.asNode().get('dependencies').get(0)
project.configurations.shadowed.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', 'runtime')
}
}
}
}

afterEvaluate {
Expand Down Expand Up @@ -1425,6 +1443,7 @@ project(':clients') {

configurations {
generator
shadowed
}

dependencies {
Expand All @@ -1435,10 +1454,10 @@ project(':clients') {
implementation libs.opentelemetryProto

// libraries which should be added as runtime dependencies in generated pom.xml should be defined here:
shadow libs.zstd
shadow libs.lz4
shadow libs.snappy
shadow libs.slf4jApi
shadowed libs.zstd
shadowed libs.lz4
shadowed libs.snappy
shadowed libs.slf4jApi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if below in shadowJar, we should do something like:

// dependencies excluded from the final jar, since they are declared as runtime dependencies
dependencies {
  project.configurations.shadowed.allDependencies.each {
    exclude(dependency(it.group + ':' + it.name))
  }
  // exclude proto files from the jar
  exclude "**/opentelemetry/proto/**/*.proto"
  exclude "**/google/protobuf/*.proto"
}

Instead of what we currently have where we again list these dependencies:

exclude(dependency(libs.snappy))
exclude(dependency(libs.zstd))
exclude(dependency(libs.lz4))
exclude(dependency(libs.slf4jApi))

This would avoid having these diverge in the future. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I ll give it a try next week.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apoorvmittal10 , is there any update about the suggestion from @mimaison ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mimaison @showuon I have made the suggested change, just added version as well with the group and name. I have verified the pom, jar and manifest file they are correct.


compileOnly libs.jacksonDatabind // for SASL/OAUTHBEARER bearer token parsing
compileOnly libs.jacksonJDK8Datatypes
Expand Down Expand Up @@ -1491,10 +1510,9 @@ project(':clients') {

// dependencies excluded from the final jar, since they are declared as runtime dependencies
dependencies {
exclude(dependency(libs.snappy))
exclude(dependency(libs.zstd))
exclude(dependency(libs.lz4))
exclude(dependency(libs.slf4jApi))
project.configurations.shadowed.allDependencies.each {
exclude(dependency(it.group + ':' + it.name + ':' + it.version))
}
// exclude proto files from the jar
exclude "**/opentelemetry/proto/**/*.proto"
exclude "**/google/protobuf/*.proto"
Expand Down