注册

提出工单

image

查看审核记录

image

gpg密钥

下载位置

# 密钥生成
gpg --gen-key
# 上传公钥
gpg --keyserver hkp://keyserver.ubuntu.com:80 --send-keys 公钥

# 查看公钥是否上传成功
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 公钥

配置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">
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
        <id>sonatype-nexus-snapshots</id>
        <username>sonatype账号</username>
        <password>sonatype密码</password>
    </server>
    <server>
        <id>sonatype-nexus-staging</id>
        <username>sonatype账号</username>
        <password>sonatype密码</password>
    </server>
  </servers>
  <mirrors>
  </mirrors>
  <profiles>
     <profile>
        <id>gpg</id>
        <properties>
            <gpg.executable>gpg</gpg.executable>
            <gpg.passphrase>生成gpg时设置的密码</gpg.passphrase>
        </properties>
    </profile>
  </profiles>
  
  <activeProfiles>
    <activeProfile>gpg</activeProfile>
  </activeProfiles>

</settings>

配置环境变量应对javadoc检查

image

JAVA_TOOL_OPTIONS
-Dfile.encoding=UTF-8

配置pom.xml

<licenses>
    <license>
        <name>The Apache Software License, Version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        <distribution>repo</distribution>
    </license>
</licenses>
<scm>
    <tag>版本号</tag>
    <url>git@github.com:chenqi92/allbs-utils-core.git</url>
    <connection>scm:git:git@github.com:chenqi92/allbs-utils-core.git</connection>
    <developerConnection>scm:git:git@github.com:chenqi92/allbs-utils-core.git</developerConnection>
</scm>
<developers>
    <developer>
        <name>chenQi</name>
        <email>cq92104@outlook.com</email>
        <organization>allbs</organization>
    </developer>
</developers>

<build>
    <plugins>
        <!-- doc plugin,Maven API文档生成插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.1.0</version>
            <!-- javadoc检查跳过 -->
            <configuration>
                <failOnError>false</failOnError>
                <doclint>none</doclint>
            </configuration>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- resources plugin,Maven 资源插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- compiler plugin,Maven 编译插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
        <!-- gpg plugin,用于签名认证 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <id>sign-artifacts</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>sign</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!--staging puglin,用于自动执行发布阶段(免手动)-->
        <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>1.6.8</version>
            <extensions>true</extensions>
            <configuration>
                <serverId>sonatype-nexus-snapshots</serverId>
                <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
        </plugin>
        <!-- release plugin,用于发布到release仓库部署插件 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.4.2</version>
        </plugin>
    </plugins>
</build>

<distributionManagement>
    <snapshotRepository>
        <id>sonatype-nexus-snapshots</id>
        <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
    </snapshotRepository>
    <repository>
        <id>sonatype-nexus-staging</id>
        <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
</distributionManagement>

执行上传命令

mvn clean deploy

如果显示build success 则说明上传并发布成功

image

image

如果自动发布失败

登录

执行以下步骤

image-20220902175005177