登录网址:https://issues.sonatype.org/login.jsp 没有则注册个账号,账号和密码后面用来登录管理jar的网址,必须记住
创建一个工单,用来在中央仓库申请自己jar包的groupId,创建后会有提示操作,按评论上面说的进行操作(一般是让你创建一个指定名称的仓库)
工单通过后,评论那里会有后面你需要上传jar到哪个中转仓库的地址
gpg安装,gpg下载地址 https://files.gpg4win.org/gpg4win-3.1.15.exe
安装好后执行命令
key要替换成自己的
gpg --version
gpg --gen-key
gpg --list-keys
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 6CF5C9C9EA061692B1C0EE066C692297592
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 6CF5C9C9EA061692B1C0EE066C692297592
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 6CF5C9C9EA061692B1C0EE066C692297592
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys 6CF5C9C9EA061692B1C0EE066C692297592
配置maven中的settings.xml文件,增加一个server服务,用来上传jar包到中转仓库
<servers>
<server>
<id>oss-releases</id>
<username>创建工单的用户名</username>
<password>密码</password>
</server>
<server>
<id>oss-snapshots</id>
<username>创建工单的用户名</username>
<password>密码</password>
</server>
</servers>
项目中的pom文件配置,自己的信息更改为自己的
<?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>com.gitee.dqhm</groupId>
<artifactId>evalidator</artifactId>
<version>1.0.3</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>false</maven.deploy.skip>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<name>${project.groupId}:${project.artifactId}</name>
<description>The test uploads the jar to the maven central repository</description>
<url>https://gitee.com/dqhm/evalidator</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>dengqianghua</name>
<email>1454868983@qq.com</email>
<organization>dqhm</organization>
<organizationUrl>https://gitee.com/dqhm/evalidator</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://gitee.com/dqhm/evalidator.git</connection>
<developerConnection>scm:git:ssh://gitee.com/dqhm/evalidator.git</developerConnection>
<url>https://gitee.com/dqhm/evalidator/tree/master</url>
</scm>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>oss-snapshots</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>oss-releases</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- GPG -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
执行上传命令
mvn clean deploy -Prelease
在中转仓库校验上传的jar包是否符合要求
点击colse后,会执行上传校验,在activity里面可以看到,存在问题会有提示的
上传到中央仓库,上传成功后这个会可点击,上传即可,大概2小时左右就可以在中央仓库查看到自己上传的jar包了