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

Incorrect publication file referenced with gradle signing and publication #901

Open
apoorvmittal10 opened this issue Feb 2, 2024 · 1 comment

Comments

@apoorvmittal10
Copy link

Shadow Version

'com.github.johnrengelman.shadow' version '8.1.1'

Gradle Version

8.5

Expected Behavior

The shadow jar artifact should be signed and published to repository.

Actual Behavior

The publication does not find the shadow jar artifact and errors out.

I have debugged the issue, and the issue occurs only when signing kicks off i.e. without signing the artifacts are referenced and published correctly. Further debugging revealed the issue exists because archiveBaseName and archiveClassifier are not honoured correctly by publication and tries to find the shadow jar which doesn't exist.

> * What went wrong:
> Execution failed for task ':clients:publishMavenJavaPublicationToMavenRepository'.
> > Failed to publish publication 'mavenJava' to repository 'maven'
>    > Invalid publication 'mavenJava': artifact file does not exist: '/Users/apoorvmittal/kafka/.release_work_dir/kafka/clients/build/libs/clients-3.7.0-all.jar'

I have placed a workaround here which does solve the issue but introduces other where resultant pom doesn't include runtime dependencies.

Fix - Probable problem with version 8.1.1

Further debugging revealed that issue exists with 8.1.1 version and downgrading to 8.1.0 plugin version works correctly.

Gradle Build Script(s)

Reference the complete script - here

plugins {
  ...
  ...
  id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
  ...
}
...
...
if (shouldPublish) {

    publishing {
      ...
      publications {
        mavenJava(MavenPublication) {
          if (!shouldPublishWithShadow) {
            from components.java
          } else {
            apply plugin: 'com.github.johnrengelman.shadow'
            project.shadow.component(mavenJava)
          }

          ...
          ...
        }
      }
    }

    if (shouldSign) {
      signing {
        sign publishing.publications.mavenJava
      }
    }
...
...
project(':clients') {
  archivesBaseName = "kafka-clients"

  ...
  ...
  shadowJar {
    ...
    archiveClassifier = null
    ...
    ...
}

@Goooler
Copy link
Contributor

Goooler commented Feb 20, 2024

Duplicate of #860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants