Search code examples
javagradlegroovy

Gradle Invalid publication 'shadow': multiple artifacts with the identical extension and classifier ('jar', 'all')


I discovered to day that the published artifact didn't include my shaded libraries. I would like to have them inside so I decided to edit my publishing section inside my build.gradle

publishing {
    repositories {
        maven {
            name = "GitHubPackages"
            url = "https://maven.pkg.github.com/oraxen/Oraxen"
            credentials {
                username = System.getenv("GITHUB_ACTOR")
                password = System.getenv("GITHUB_TOKEN")
            }
        }
    }
    publications {
        shadow(MavenPublication) {
            from components.java
            artifact shadowJar
        }
    }
}
// entire file: https://github.com/oraxen/oraxen/blob/06ca465c8854c9e3df386a608845d86852e70560/build.gradle

Unfortunately I got this error:

Execution failed for task ':publishShadowPublicationToGitHubPackagesRepository'.
> Failed to publish publication 'shadow' to repository 'GitHubPackages'
   > Invalid publication 'shadow': multiple artifacts with the identical extension and classifier ('jar', 'all').

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

How can I specify that I want to upload the -all artifact?


Solution

  • components.java should contain the shadow jar and the original jar, so simply remove the artifact shadowJar line will work.