maven 中央仓库发布
Last updated on November 20, 2024 am
🧙 Questions
发布jar到中央仓库
☄️ Ideas
申请账号
申请项目
申请项目 https://issues.sonatype.org/secure/Signup.jspa
- 项目:Community Support - Open Source Project Repository Hosting (OSSRH)
- 问题类型:New Project
- 概要:for new project spark-star
- 描述:for new project spark-star
- Group Id: com.isxcode.star
- Project Url:https://github.com/ispong/spark-star
- SCM Url:https://github.com/ispong/spark-star.git
- Username:ispong
跟踪问题进度
阿里云域名确认
OSSRH-75860
https://issues.sonatype.org/browse/OSSRH-75860
回应问题,等待回复
GPG安装
- gpg安装
构建项目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>com.isxcode.star</groupId>
<artifactId>star-common</artifactId>
<version>0.0.1</version>
<name>star-common</name>
<url>https://github.com/ispong/spark-star</url>
<description>star-common</description>
<!-- 变量配置 -->
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- 项目依赖 -->
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- 许可证信息 -->
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<!-- 开发者信息 -->
<developers>
<developer>
<name>ispong</name>
<email>ispong@outlook.com</email>
</developer>
</developers>
<!-- 仓库信息 -->
<scm>
<connection>scm:git:git://github.com/ispong/spark-star.git</connection>
<developerConnection>scm:git:ssh://github.com/ispong/spark-star.git</developerConnection>
<url>https://github.com/ispong/spark-star</url>
</scm>
<!-- 指定需要发布到哪个中央仓库 -->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<!-- 构建配置 -->
<build>
<plugins>
<!-- 此插件会自动发布正式版本,不需要手动release -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<!-- ispong :) 和settings.xml server标签内id保持一致 -->
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- 给文件添加gpg加密,发布正式版本必须要阳台要验证gpg -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<executable>gpg</executable>
<keyname>0x7219EB0C</keyname>
</configuration>
</execution>
</executions>
</plugin>
<!-- 生成项目source文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 生成项目docs文件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<phase>package</phase>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
修改maven全局settings.xml
Note:
此处需要添加一开始注册的账号密码
id中输入的值必须和项目中pom.xml中distributionManagement.snapshotRepository.id
保持一致
<servers>
<server>
<id>ossrh</id>
<username>${username}</username>
<password>${password}</password>
</server>
</servers>
发布jar到中央仓库
mvn clean package deploy
🔗 Links
maven 中央仓库发布
https://ispong.isxcode.com/spring/maven/maven 中央仓库发布/