【问题标题】:Missing checksum files when using Gradle maven-publish and signing plugins使用 Gradle maven-publish 和签名插件时缺少校验和文件
【发布时间】:2019-11-13 14:11:09
【问题描述】:

我有一个使用 Gradle 构建和打包的 Java 项目。我的目的是创建发布到 Maven Central 的工件。

作为第一步,我配置了我的 Gradle 项目,如文档中的以下示例所示:

https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example

当我运行 gradle publishToMavenLocal 时,我在本地存储库中安装了以下文件:

maven-metadata-local.xml
my-library-1.0.2-SNAPSHOT.jar
my-library-1.0.2-SNAPSHOT.jar.asc
my-library-1.0.2-SNAPSHOT-javadoc.jar
my-library-1.0.2-SNAPSHOT-javadoc.jar.asc
my-library-1.0.2-SNAPSHOT.pom
my-library-1.0.2-SNAPSHOT.pom.asc
my-library-1.0.2-SNAPSHOT-sources.jar
my-library-1.0.2-SNAPSHOT-sources.jar.asc

文件一切正常。我唯一的问题是没有生成校验和文件(md5 和 sha1)。但是,校验和文件是通过 OSS Sonatype 在 Maven Central 上部署工件的要求。

如何生成丢失的校验和文件?似乎 maven-publishsigning 插件没有用于此目的的选项?怎么了?

【问题讨论】:

    标签: maven gradle sonatype maven-central maven-publish


    【解决方案1】:

    我找到的解决方案是使用shadowant.checksum

    tasks.withType(Jar) { task ->
        task.doLast {
            ant.checksum algorithm: 'md5', file: it.archivePath
            ant.checksum algorithm: 'sha1', file: it.archivePath
            ant.checksum algorithm: 'sha-256', file: it.archivePath, fileext: '.sha256'
            ant.checksum algorithm: 'sha-512', file: it.archivePath, fileext: '.sha512'
        }
    }
    

    调用gradle publishShadowPublicationToMavenLocal 将根据需要生成签名,但不会将它们发布到~/.m2

    起初我以为那些签名应该是自动的,所以我打开https://github.com/johnrengelman/shadow/issues/718讨论。

    【讨论】:

      猜你喜欢
      • 2020-11-17
      • 2021-03-31
      • 2021-02-21
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      • 2021-12-25
      相关资源
      最近更新 更多