Skip to content

Publishing a KMP project with signing fails with "Task ... uses this output of task ... without declaring an explicit or implicit dependency" #26091

@arkivanov

Description

@arkivanov

Current Behavior

Publication fails with:

> Task :signJvmPublication FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':signJvmPublication' (type 'Sign').
  - Gradle detected a problem with the following location: '/Users/arkivanov/dev/workspace/api-validator-issue/build/libs/publish-issue-0.0.1-javadoc.jar.asc'.
    
    Reason: Task ':publishJsPublicationToMavenLocal' uses this output of task ':signJvmPublication' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':signJvmPublication' as an input of ':publishJsPublicationToMavenLocal'.
      2. Declare an explicit dependency on ':signJvmPublication' from ':publishJsPublicationToMavenLocal' using Task#dependsOn.
      3. Declare an explicit dependency on ':signJvmPublication' from ':publishJsPublicationToMavenLocal' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Expected Behavior

No errors and artifacts uploaded.

Context (optional)

This started to happen after upgrade to from Gradle 7.5 to 8.2.1. I'm not sure yet if it's only related to KMP projects. There is a discussion of this issue in KT-46466, but the ticket has been closed as "Third Party Problem".

One of the suggested workaround:

val signingTasks = tasks.withType<Sign>()
tasks.withType<AbstractPublishToMaven>().configureEach {
  dependsOn(signingTasks)
}

Steps to Reproduce

  1. Extract the reproducer: publish-issue.zip
  2. cd into the directory
  3. export SIGNING_KEY=$(cat <path to some private key armored ascii>)
  4. export SIGNING_PASSWORD=<password for the key>
  5. ./gradlew publishToMavenLocal

Gradle version

8.2.1

Build scan URL (optional)

https://gradle.com/s/xhbyr2vn27rpu

Your Environment (optional)

macOS Ventura 13.5
openjdk 17.0.8 2023-07-18

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions