如何将jar包上传到Maven中央仓库
来源:互联网 发布:温柔知乎 编辑:程序博客网 时间:2024/03/28 20:32
最近actable的部分功能已经完善了,一些小伙伴已经在使用了,但是由于没有放到远程仓库,导致使用的小伙伴都需要自己将代码取下来,然后install,这样不太好,所以最近就规划了下包结构,上传到了maven中央仓库中,以下是上传步骤。
1.创建工单
1.1 https://issues.sonatype.org/secure/Dashboard.jspa新建一个账号,登录后选择Create Issue,选择Community Support - Open Source Project Repository Hosting (OSSRH)以及New Project,其他按照你自己的项目情况填写。
2.等待回复
2.1 发布完后几小时内会有工作人员问你是否有Group Id对应的那个域名的所有权,如果有的话就回复有,然后就会得到Configuration has been prepared的回复,这个时候就可以准备发布了。如果自己没有域名的话可以挂在开源的域名下面,例如com.gitee.sunchenbin,这样一样可以发布。2.2 下面是我的项目的几次回复,最终状态变为Resolved的时候表示你有权限可以上传东西了。
3.使用gpg生成密钥
3.1我这里使用的是windows,直接用的Git Gui的git-bash.exe如下
$ gpg --gen-keygpg (GnuPG) 1.4.21; Copyright (C) 2015 Free Software Foundation, Inc.This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only)Your selection?RSA keys may be between 1024 and 4096 bits long.What keysize do you want? (2048)Requested keysize is 2048 bitsPlease 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 yearsKey is valid for? (0)Key does not expire at allIs this correct? (y/N) yYou need a user ID to identify your key; the software constructs the user IDfrom the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"Real name: sunchenbinEmail address: sunchenbinkey@163.comComment:You selected this USER-ID: "sunchenbin <sunchenbinkey@163.com>"Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? oYou need a Passphrase to protect your secret key.We need to generate a lot of random bytes. It is a good idea to performsome other action (type on the keyboard, move the mouse, utilize thedisks) during the prime generation; this gives the random numbergenerator a better chance to gain enough entropy.......+++++.....+++++We need to generate a lot of random bytes. It is a good idea to performsome other action (type on the keyboard, move the mouse, utilize thedisks) during the prime generation; this gives the random numbergenerator a better chance to gain enough entropy.........++++++++++gpg: key 09D71290 marked as ultimately trustedpublic and secret key created and signed.gpg: checking the trustdbgpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust modelgpg: depth: 0 valid: 2 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 2upub 2048R/09D71290 2017-11-13 Key fingerprint = 6A67 3904 E8BB F8D6 780B CC5D 65E4 DAD5 09D7 1290uid sunchenbin <sunchenbinkey@163.com>sub 2048R/23D05BFD 2017-11-13
这样密钥就产生了,You need a Passphrase to protect your secret key.注意这里输入的密码,后续上传到maven中央仓库是需要用到的。3.2 上传密钥首先查看自己key的编号:gpg --list-keys找到 pub对应的那个编号,例如pub 2048R/8C473F5C 上传到key验证库:gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 8C473F5C
4.配置pom.xml
4.1 pom中增加如下的配置就好
<parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>7</version> </parent> <name>com.gitee.sunchenbin.mybatis.actable:mybatis-enhance-actable</name> <description>A.CTable is a Maven project based on Spring and Mybatis, which enhances the function of Mybatis</description> <url>https://gitee.com/sunchenbin/mybatis-enhance</url> <licenses> <license> <name>The Apache Software License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>actable</distribution> </license> </licenses> <developers> <developer> <name>sunchenbin</name> <email>458757617@qq.com</email> <organization>sunchenbin</organization> <url>https://gitee.com/sunchenbin/mybatis-enhance</url> </developer> </developers> <scm> <connection>scm:git:git@gitee.com:sunchenbin/mybatis-enhance.git</connection> <developerConnection>scm:git:git@gitee.com:sunchenbin/mybatis-enhance.git</developerConnection> <url>https://gitee.com/sunchenbin/mybatis-enhance</url> <tag>1.0</tag> </scm> <distributionManagement> <snapshotRepository> <!-- 这个id需要在setting.xml中设置 --> <id>oss</id> <name>OSS Snapshots Repository</name> <!-- 这里的url就是Issue中回复的snapshots 的repo地址--> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>oss</id> <name>OSS Staging Repository</name> <!-- 这里的url就是Issue中回复的staging 的repo地址--> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement>
4.2 配置Maven的settings.xml
<servers> <server> <id>sonatype-nexus-snapshots</id> <username>上面第一步时注册的帐号</username> <password>上面第一步时注册的密码</password> </server> <server> <id>sonatype-nexus-staging</id> <username>上面第一步时注册的帐号</username> <password>上面第一步时注册的密码</password> </server></servers>
5.部署上传jar包
命令行进入到项目pom.xml所在的目录下,运行如下命令:
mvn clean deploy -P sonatype-oss-release -Darguments="gpg.passphrase=设置gpg设置密钥时候输入的Passphrase"
过程中可能需要你手动输入密码。
6.release jar包
如果前几个步骤全部正确完成,登录https://oss.sonatype.org/#stagingRepositories(用户名密码就是第一步注册时的用户名密码),将Staging Rpositories拉到最下即可看到你刚刚发布的jar包,选择上方的Close,稍等片刻他先检查一下你上传的东西是否符合规范,检查完毕后该条状态被标记为closed,此时选中后点上面的Release即可,等2个小时左右即可在http://search.maven.org/看到你发布的jar包。
阅读全文
2 0
- 如何将jar包上传到Maven中央仓库
- 如何把自己的Jar包上传到 maven 官方仓库中,Maven上传图文讲解
- 用eclipse怎样将本地的项目打成jar包上传到maven仓库
- 怎样将jar包上传到Sonatype Nexus仓库
- 如何通过网页方式将jar包上传到nexus
- 如何通过网页方式将jar包上传到nexus
- 如何通过网页方式将jar包上传到nexus?
- 用eclipse怎样将本地的项目打成jar包上传到mevan仓库
- 将jar发布到maven中央仓库小记
- 将jar发布到maven中央仓库小记
- 将jar发布到maven中央仓库小记
- Maven中央仓库jar下载
- 如何发布jar包到maven中央仓库
- 获得maven地址,如何从中央仓库中下载jar
- 如何发布自己的 jar 包到 maven 中央仓库
- 获得maven地址,如何从中央仓库中下载jar
- 获得maven地址,如何从中央仓库中下载jar
- iOS 如何利用Application Loader 将ipa包上传到AppStore
- 机器学习——神经网络模型构建方法
- linux系统(centos6.5)初始化安装及部署
- Python 3 的数据类型和基本处理
- 虚拟内存机制
- 753个大奖邀请各位新老博主入驻云栖,请技术人员广而告之
- 如何将jar包上传到Maven中央仓库
- UEditor富文本框(附件上传)
- 数据中心业界迎来机器学习工具
- 唯快不破:TCP的那些事儿(上篇)
- 深度学习提速280%! 未来GPU在计算机领域的地位将会如何?
- Error:Execution failed for task ':app:transformDexWithDexForRelease'.
- 腾讯应用管理中心,认领应用
- 如何查看linux 操作系统版本
- SDUT 2147 表达式语法分析——递归子程序法