自己上传开源库到Maven

  1. 创建sonatype账号;提一个JIRA单,可以参考我的提单

    • 可能会有github的验证,按照JIRA单的评论进行操作即可
  2. 创建密钥

    • 密钥有分为私有密钥和公开密钥,私有私钥需要配置到项目中,公开密钥上传到服务器

    • 密钥类型选择RSA and RSA

    • windows安装gpg4win创建密钥,使用命令行操作示例,如下:(用gui操作默认密钥类型不是RSA and RSA,上传到服务器也有问题)

      # 生成密钥
      C:\Users\Administrator>gpg --full-generate-key
      gpg (GnuPG) 2.4.0; Copyright (C) 2021 g10 Code GmbH
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
      
      # 类型一定要选(1) RSA and RSA
      Please select what kind of key you want:
         (1) RSA and RSA
         (2) DSA and Elgamal
         (3) DSA (sign only)
         (4) RSA (sign only)
         (9) ECC (sign and encrypt) *default*
        (10) ECC (sign only)
        (14) Existing key from card
      Your selection? 1
      RSA keys may be between 1024 and 4096 bits long.
      What keysize do you want? (3072)
      Requested keysize is 3072 bits
      Please specify how long the key should be valid.
               0 = key does not expire
            <n>  = key expires in n days
            <n>w = key expires in n weeks
            <n>m = key expires in n months
            <n>y = key expires in n years
      Key is valid for? (0) 0
      Key does not expire at all
      Is this correct? (y/N) y
      
      GnuPG needs to construct a user ID to identify your key.
      
      Real name: wdp
      Email address: 927718579@qq.com
      Comment: wdp-gpg
      You selected this USER-ID:
          "wdp (wdp-gpg) <[email protected]>"
      
      Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
      We need to generate a lot of random bytes. It is a good idea to perform
      some other action (type on the keyboard, move the mouse, utilize the
      disks) during the prime generation; this gives the random number
      generator a better chance to gain enough entropy.
      We need to generate a lot of random bytes. It is a good idea to perform
      some other action (type on the keyboard, move the mouse, utilize the
      disks) during the prime generation; this gives the random number
      generator a better chance to gain enough entropy.
      gpg: revocation certificate stored as 'C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\openpgp-revocs.d\\F7E901A90444D1A8B91EA9163CA132CF1D4A5B0A.rev'
      public and secret key created and signed.
      
      pub   rsa3072 2023-04-21 [SC]
            F7E901A90444D1A8B91EA9163CA132CF1D4A5B0A
      uid                      wdp (wdp-gpg) <927718579@qq.com>
      sub   rsa3072 2023-04-21 [E]
      
      # 创建私有密钥
      C:\Users\Administrator>gpg --export-secret-keys > secret.gpg
      # 将公开密钥上传到服务器
      C:\Users\Administrator>gpg --keyserver keyserver.ubuntu.com --send-keys
      
  3. 配置gradle脚本

    • 可以先本地生成一下,没有问题在上传到maven,脚本可以复制这个博客:

      https://blog.csdn.net/qq_20489601/article/details/123916777

  4. 发布

    进入maven管理后台, Staging Repositories --> open --> close --> release

  5. 使用:例如implementation 'io.github.dongpingwang:AndroidSerialPort:1.0.0'

猜你喜欢

转载自blog.csdn.net/wangadping/article/details/130321555