当前位置: 首页 > news >正文

把自己的垃圾代码发布到官方中央仓库

参考博客:将组件发布到maven中央仓库-CSDN博客 感谢这位博主。但是他的步骤有漏缺,相对进行补充

访问管理页面

网址:Maven Central

新注册账号,或者使用github快捷登录,建议使用github快捷登录

添加命名空间

注意,如果使用github快捷登录,默认携带 io.github.?? 的命名空间,如果自己的代码在github上,可以直接使用这个命名空间

如果代码在 码云 仓库,

提交后,提示需要验证空间,需要按照要求,到 码云 仓库创建一个对应名称的空内容的项目,然后点击认证。

如上图, io.gitee.wsitm 是我的命名空间

添加其他命名空间见 Register a Namespace - The Central Repository Documentation

创建代码仓库

注意:代码一定需要符合开源,可以使用MIT开源,或其他开源。创建开源极为容易,gitee默认会提示创建开源,有快捷入口,点击快速创建。

代码的pom.xml的配置

具体如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>io.gitee.wsitm</groupId><artifactId>wsitm-clutter</artifactId><version>0.0.1</version><url>https://gitee.com/wsitm/wsitm-clutter.git</url><packaging>jar</packaging><name>${project.artifactId}</name><description>wsitm-clutter杂烩工具</description><dependencies></dependencies><licenses><license><name>MIT License</name><url>https://opensource.org/licenses/MIT</url><comments>The project itself is licensed under MIT License.</comments></license></licenses><developers><developer><name>yourname</name><email>youremail@qq.com</email></developer></developers><scm><connection>scm:git@gitee.com:wsitm/wsitm-clutter.git</connection><developerConnection>scm:git@gitee.com:wsitm/wsitm-clutter.git</developerConnection><url>https://gitee.com/wsitm/wsitm-clutter.git</url></scm><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>3.3.0</version><executions><execution><id>attach-sources</id><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9.1</version><configuration><aggregate>true</aggregate><charset>UTF-8</charset><encoding>UTF-8</encoding><docencoding>UTF-8</docencoding><additionalparam>-Xdoclint:none</additionalparam></configuration><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>3.1.0</version><executions><execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions></plugin><!--maven插件--><plugin><groupId>org.sonatype.central</groupId><artifactId>central-publishing-maven-plugin</artifactId><version>0.4.0</version><extensions>true</extensions><configuration><publishingServerId>central</publishingServerId><tokenAuth>true</tokenAuth></configuration></plugin></plugins></build>
</project>

生成GPG密钥

作用:这是用于给自身源码加签名

下载GPG管理软件:https://gnupg.org/download/index.html


点击进入下载页面

如上图,当然,如果有钱也可以捐献一些。我不一样,我白嫖

安装完成之后,使用命令生成密钥,命令:  gpg –gen-key

生成之后

推送密钥到远程服务端

命令:  gpg --keyserver hkp://keyserver.ubuntu.com --send-keys [生成密钥后的标识]

例子:gpg --keyserver hkp://keyserver.ubuntu.com --send-keys 2*************F6449

服务:--keyserver 有三个官方网址可以切换

  • keyserver.ubuntu.com
  • keys.openpgp.org
  • pgp.mit.edu

注意:可能推送不成功,三个网址我都测试不成功,不知道什么原因,只能使用另一种方法

公钥如下:

复制全部内容,手动上传,打开服务网址:  https://keyserver.ubuntu.com/#

生成token

得到的token格式如下:

maven的setting.xml的配置

具体如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><servers><server><id>central</id><username>${tokenId}</username><password>${tokenPass}</password></server></servers><profiles><profile><id>gpg</id><properties><gpg.executable>gpg</gpg.executable><gpg.keyname>youremail@qq.com</gpg.keyname><gpg.passphrase>${pgp-password}</gpg.passphrase><gpg.useagent>true</gpg.useagent></properties></profile></profiles>
</settings>

发布到仓库

进入代码目录,执行命令:  mvn clean deploy

发布完成,打开管理页面


提交后需要验证,如果正常

如果异常,查看错误描述

去仓库查看自己的项目

阿里云:  仓库服务

官方:  Central Repository:

官方页面:https://mvnrepository.com/

注:阿里云,和官方能在审核后1小时内能查到自己的项目,但是官方页面需要好多天才能查询。但直接在maven中引用即可,并不影响使用

相关文章:

  • 自定义数据集上的3D目标检测:使用OpenPCDet训练CenterPointPillar模型
  • Vue速成学习笔记
  • 通过LLM多轮对话生成单元测试用例
  • vmware中Ubuntu虚拟机和本地电脑Win10互相ping通
  • Reddit是什么?跨境独立站卖家如何用Reddit营销?
  • LangChain入门开发教程(一):Model I/O
  • CompletableFuture详细讲解
  • 【MySQL精通之路】全文搜索(5)-限制
  • Java break细节(标签)
  • Linux: network: tcp spurious retrans 的一个原因
  • C 语言实例 - 表格形式输出数据
  • Python打包篇-exe
  • MFC工控项目实例之一主菜单制作
  • 【MATLAB源码-第217期】基于matlab的16QAM系统相位偏移估计HOS算法仿真,对比补偿前后的星座图误码率。
  • Kubernetes 容器编排
  • 《Java编程思想》读书笔记-对象导论
  • canvas 五子棋游戏
  • co.js - 让异步代码同步化
  • E-HPC支持多队列管理和自动伸缩
  • Eureka 2.0 开源流产,真的对你影响很大吗?
  • javascript从右向左截取指定位数字符的3种方法
  • jQuery(一)
  • JSDuck 与 AngularJS 融合技巧
  • Laravel 菜鸟晋级之路
  • SpiderData 2019年2月23日 DApp数据排行榜
  • Traffic-Sign Detection and Classification in the Wild 论文笔记
  • use Google search engine
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • 服务器从安装到部署全过程(二)
  • 前端路由实现-history
  • 为什么要用IPython/Jupyter?
  • 小程序开发中的那些坑
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • 异常机制详解
  • 正则表达式
  • const的用法,特别是用在函数前面与后面的区别
  • ​软考-高级-系统架构设计师教程(清华第2版)【第12章 信息系统架构设计理论与实践(P420~465)-思维导图】​
  • # Redis 入门到精通(八)-- 服务器配置-redis.conf配置与高级数据类型
  • # 透过事物看本质的能力怎么培养?
  • #systemverilog# 之 event region 和 timeslot 仿真调度(十)高层次视角看仿真调度事件的发生
  • $Django python中使用redis, django中使用(封装了),redis开启事务(管道)
  • (06)金属布线——为半导体注入生命的连接
  • (13)Hive调优——动态分区导致的小文件问题
  • (C语言)strcpy与strcpy详解,与模拟实现
  • (delphi11最新学习资料) Object Pascal 学习笔记---第7章第3节(封装和窗体)
  • (过滤器)Filter和(监听器)listener
  • (深度全面解析)ChatGPT的重大更新给创业者带来了哪些红利机会
  • (学习日记)2024.03.25:UCOSIII第二十二节:系统启动流程详解
  • (译)2019年前端性能优化清单 — 下篇
  • (源码分析)springsecurity认证授权
  • (转)nsfocus-绿盟科技笔试题目
  • (转)菜鸟学数据库(三)——存储过程
  • (转)人的集合论——移山之道
  • .bat批处理(八):各种形式的变量%0、%i、%%i、var、%var%、!var!的含义和区别
  • .NET命名规范和开发约定