maven如何發(fā)布jar到中央倉(cāng)庫(kù)

本篇內(nèi)容主要講解“maven如何發(fā)布jar到中央倉(cāng)庫(kù)”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“maven如何發(fā)布jar到中央倉(cāng)庫(kù)”吧!

創(chuàng)新互聯(lián)公司執(zhí)著的堅(jiān)持網(wǎng)站建設(shè),微信小程序開發(fā);我們不會(huì)轉(zhuǎn)行,已經(jīng)持續(xù)穩(wěn)定運(yùn)營(yíng)十多年。專業(yè)的技術(shù),豐富的成功經(jīng)驗(yàn)和創(chuàng)作思維,提供一站式互聯(lián)網(wǎng)解決方案,以客戶的口碑塑造品牌,攜手廣大客戶,共同發(fā)展進(jìn)步。

1、下載 gpg4win

2、gpg --full-generate-key 或者 gpg --gen-key 生成秘鑰

C:\WINDOWS\system32>gpg --gen-key
gpg (GnuPG) 2.0.30; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1  #選擇密鑰類型(這里我們選擇加密算法是RSA、數(shù)字簽名算法也是RSA)
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048 #設(shè)置密鑰的比特?cái)?shù)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0  #設(shè)置密鑰有效期(永不過(guò)期)
Key does not expire at all
Is this correct? (y/N) y  #確認(rèn)有效性

GnuPG needs to construct a user ID to identify your key.

Real name: Ron   #輸入姓名
Name must be at least 5 characters long  #姓名至少為5個(gè)字符
Real name: ron.zheng   #輸入姓名
Email address: ron.zheng@tfschange.com  #輸入郵箱地址
Comment: tfs #輸入備注
You selected this USER-ID:
    "ron.zheng (tfs) <ron.zheng@tfschange.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o  #選擇OK
You need a Passphrase to protect your secret key.  #彈出口令輸入界面

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key 0452FE75 marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u
pub   2048R/0452FE75 2019-03-28
      Key fingerprint = 65B4 846F 7E63 A32B 34E3  A9FB C99D B8B9 0452 FE75
uid       [ultimate] ron.zheng (tfs) <ron.zheng@tfschange.com>
sub   2048R/488F27D2 2019-03-28


//輸入命令查看生成的秘鑰
gpg --list-secret-keys --keyid-format LONG
sec   rsa2048/XXXXXXXXX 2020-09-22 [SC]
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
uid                 [ultimate] fashionbrot (描述) <fashionbrot@163.com>
ssb   rsa2048/xoxoxoxoxo 2020-09-22 [E]

//然后公鑰上傳服務(wù)器  (XXXXXXXXX)是sec    rsa2048/后面的
gpg --keyserver hkp://pool.sks-keyservers.net:11371 --send-keys XXXXXXXXX
gpg --keyserver keyserver.ubuntu.com --send-keys XXXXXXXXX
gpg --keyserver pgp.mit.edu --send-keys XXXXXXXXX
gpg --keyserver keys.gnupg.net --send-keys XXXXXXXXX

maven 配置增加

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>com.facebook.thrift:com.facebook.thrift.*</excludePackageNames>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <doclint>none</doclint>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                    <!-- -Dgpg.passphrase='秘鑰密碼'或者-Darguments='gpg.passphrase=秘鑰密碼' -->
                </executions>
            </plugin>
        </plugins>
    </build>

運(yùn)行maven 命令

mvn  -Dmaven.test.skip=true verify -Dgpg.passphrase="秘鑰密碼"

然后target 下會(huì)生成一下文件 mvn -Dmaven.test.skip=true verify -Dgpg.passphrase="秘鑰密碼"

mars-validated-1.0.3.pom
mars-validated-1.0.3.jar
mars-validated-1.0.3.jar.as
mars-validated-1.0.3.pom.asc
mars-validated-1.0.3-javadoc.jar
mars-validated-1.0.3-javadoc.jar.asc
mars-validated-1.0.3-sources.jar
mars-validated-1.0.3-sources.jar.asc

然后訪問(wèn)https://oss.sonatype.org/ 進(jìn)行登錄

左側(cè)菜單選擇 >Staging Upload

1、Upload Mode: 選擇 Artifact(s) with a POM2、Select Pom to Upload 選擇 mars-validated-1.0.3.pom上傳3、Select Artifact(s) to Upload 選擇以下7個(gè)文件一個(gè)一個(gè)的添加

mars-validated-1.0.3.jar
mars-validated-1.0.3.jar.as
mars-validated-1.0.3.pom.asc
mars-validated-1.0.3-javadoc.jar
mars-validated-1.0.3-javadoc.jar.asc
mars-validated-1.0.3-sources.jar
mars-validated-1.0.3-sources.jar.asc

4、 Upload Artifact(s) 上傳

然后進(jìn)入發(fā)布頁(yè)面左側(cè) -》Staging Repositories

1、先刷新然后選擇你上傳的jar (比較慢多等會(huì))直到出現(xiàn) Release 按鈕,才算是jar包發(fā)布成功。如果沒(méi)有出現(xiàn),則表示jar簽名出現(xiàn)錯(cuò)誤。最后選中jar Release 發(fā)布即可

發(fā)布成功后1~2天才能在中央倉(cāng)庫(kù)看到。1天后就可以下載到

到此,相信大家對(duì)“maven如何發(fā)布jar到中央倉(cāng)庫(kù)”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

分享名稱:maven如何發(fā)布jar到中央倉(cāng)庫(kù)
網(wǎng)頁(yè)URL:http://muchs.cn/article0/ippooo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、標(biāo)簽優(yōu)化App開發(fā)、外貿(mào)網(wǎng)站建設(shè)靜態(tài)網(wǎng)站、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名