Gradle 无效发布“shadow”:具有相同扩展名和分类器的多个工件(“jar”、“all”)

Th0*_*gal 10 java groovy gradle

今天我发现发布的工件不包括我的阴影库。我想把它们放在里面,所以我决定在 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
Run Code Online (Sandbox Code Playgroud)

不幸的是我收到了这个错误:

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.

Run Code Online (Sandbox Code Playgroud)

如何指定我要上传 -all 工件?

the*_*ity 14

components.java应包含影子罐子和原始罐子,因此只需删除该artifact shadowJar行即可。