Skip to content

Incorrect publication file referenced with gradle signing and publication #901

@apoorvmittal10

Description

@apoorvmittal10

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
    ...
    ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions