上傳自己的jar包到maven中央倉庫

申請賬號

新建項目(github or gitee)

  • 新建項目,上傳到github或者gitee
  • 下面創(chuàng)建工單的git源使用

申請權(quán)限

  • 登錄上面的賬號,創(chuàng)建工單


    image.png
  • 根據(jù)工單的要求,進行對應(yīng)的工作,最終工單變?yōu)橐研迯?fù)即可

加密驗簽

  • 下載gpg來生產(chǎn)秘鑰對

    查看是否安裝成功
    gpg --version
    
    生成密鑰對
    gpg --gen-key
    
    查看公鑰
    gpg --list-keys
    
    將公鑰發(fā)布到PGP密鑰服務(wù)器
    gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 公鑰ID
    
    查詢公鑰是否發(fā)布成功
    gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys
    
  • 創(chuàng)建秘鑰對

  • 相關(guān)參數(shù)
    name: XXXX
    mail: xxxx@163.com
    password:  xxxxx
    
    gpg: /Users/wuwenjie/.gnupg/trustdb.gpg:建立了信任度數(shù)據(jù)庫
    gpg: 密鑰 D6BFCDEA66953384 被標記為絕對信任
    gpg: 目錄‘/Users/wuwenjie/.gnupg/openpgp-revocs.d’已創(chuàng)建
    gpg: 吊銷證書已被存儲為‘/Users/wuwenjie/.gnupg/openpgp-revocs.d/233FA1BE7CACA65156AFCD0ED6BFCDEA66953384.rev’
    公鑰和私鑰已經(jīng)生成并被簽名。
    
    pub   rsa2048 2020-04-26 [SC] [有效至:2022-04-26]
          233FA1BE7CACA65156AFCD0ED6BFCDEA66953384
    uid                      kuixin <zjkxtech@163.com>
    sub   rsa2048 2020-04-26 [E] [有效至:2022-04-26]
    

配置maven與項目的pom文件

maven setting.xml

<server>
    <id>oss</id>
    <username>kx</username>
    <password>oRVJqmU30Rbc%</password>
</server>
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.gitee.xxx</groupId>
    <artifactId>xx-tools</artifactId>
    <version>1.0</version>
    <name>xx-tools</name>
    <description>Spring Boot tools for phone,ip</description>
    <url>https://gitee.com/xxx/xx-tools</url>
    <!-- 開源簽名證書 -->
    <licenses>
        <license>
            <name>The MIT License</name>
            <url>http://opensource.org/licenses/MIT</url>
        </license>
    </licenses>
    <!-- 開發(fā)人員信息 -->
    <developers>
        <developer>
            <name>xxxx</name>
            <email>xxxx@163.com</email>
        </developer>
    </developers>

    <!-- 倉庫信息 -->
    <scm>
        <connection>scm:git:git://gitee.com:xxxx/xx-tools.git</connection>
        <developerConnection>scm:git:git://gitee.com:xxxx/xx-tools.git</developerConnection>
        <url>https://gitee.com/xxxx/xx-tools</url>
    </scm>


    <dependencies>


    </dependencies>
    <build>
        <plugins>
            <!-- Source -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.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.10.4</version>
                <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.5</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <distributionManagement>
        <snapshotRepository>
            <id>oss</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </snapshotRepository>
        <repository>
            <id>oss</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

</project>

打包上傳成功

  • 使用maven命令,直接進行打包即可


    image.png
  • 發(fā)布


    image.png

錯誤處理

gpg signing failed inappropriate ioctl for device Mac

$ brew install pinentry-mac
$ echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
$ killall gpg-agent
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容