简体   繁体   English

如何 GPG 签名并将 aar 直接发布到 Maven Central?

[英]How to GPG sign and publish an aar directly to Maven Central?

I'm working on properly setting up my Gradle scripts for publishing an .aar directly to Maven Central (with JFrog sunsetting Bintray , numerous resources about publishing to Bintray are no longer relevant).我正在正确设置我的 Gradle 脚本以将.aar直接发布到 Maven Central (使用JFrog 关闭 Bintray ,有关发布到 Bintray 的大量资源不再相关)。 One of the prerequisites is to have all artifacts (aar, sources jar, java-doc jar, pom.xml) uploaded alongside corresponding GPG-signature files (eg sources.jar.asc ).先决条件之一是将所有工件(aar,源 jar,java-doc jar,pom.xml)与相应的 GPG 签名文件(例如sources.jar.asc )一起上传

Following these two guides (which are very much alike), I've largely managed to do so:遵循这两个指南(非常相似),我在很大程度上设法做到了:

However, though well describing the solution using Gradle, both guides seem to focus on plain.jar's rather than.aar's.然而,虽然很好地描述了使用 Gradle 的解决方案,但两个指南似乎都关注plain.jar 而不是.aar。 In particular, I wasn't sure about what to set up as a project archive in order to put on the automated sign+publish list, as suggested:特别是,我不确定要设置什么作为项目存档以便放入自动签名+发布列表,如建议的那样:

project.artifacts {
    archives sourceJar // Ok, I have a sourceJar task - will be signed and uploaded
    archives javadocJar // I use Dokka, but got that to work by registering my dokka task
    archives jar // What's "jar"? this doesn't help much!... :-/
}

I even tried registering the output .aar file, explicitly:我什至尝试注册 output .aar文件,明确:

publications {
    android.libraryVariants.all { variant ->
        if (shouldPublishVariant(variant)) {
          // ...
          // ...

          variant.outputs.forEach { output ->
              project.artifacts {
                  archives output.outputFile // The full path of the .aar to publish!
              }
          }
        }
    }
}

But that seemed to have resulted in this flaky error:但这似乎导致了这个片状错误:

Execution failed for task ':detox:publishMavenFullReleaseAarPublicationToMavenRepository'.
> Failed to publish publication 'mavenFullReleaseAar' to repository 'maven'
   > Invalid publication 'mavenFullReleaseAar': artifact file does not exist: '.../build/outputs/aar/library-full-release.aar.asc'

I'm looking for a stable, bullet-proof solution that would sort this out end-to-end, with no flaky errors.我正在寻找一种稳定的、防弹的解决方案,可以端到端地解决这个问题,没有片状错误。

As a solution, I've found that registering the task generating the .aar as a project archive -- rather than registering the file itself, does the trick (much like as done for the sources and javadoc jars):作为一种解决方案,我发现将生成.aar任务注册为项目存档——而不是注册文件本身,就可以解决问题(就像对源代码和 javadoc jar 所做的那样):

publications {
    android.libraryVariants.all { variant ->
        if (shouldPublishVariant(variant)) {
          // ...
          // ...

          variant.outputs.forEach { output ->
              project.artifacts {
                  // For example: bundleProdReleaseAar is the task that generates library-prod-release.aar
                  archives project.tasks["bundle${variant.name.capitalize()}Aar"]
              }
          }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM