maven倉庫jar包發佈指南

install gpg

brew install gnupg

check

➜  ~ gpg --version
gpg (GnuPG) 1.4.20
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
支持的算法:
公鑰:RSA, RSA-E, RSA-S, ELG-E, DSA
對稱加密:IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256,
               TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
散列:MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
壓縮:不壓縮, ZIP, ZLIB, BZIP2

生成密鑰對

gpg --gen-key

查看公鑰

gpg --list-keys

將公鑰發佈到 PGP 密鑰服務器

gpg --keyserver hkp://pool.sks-keyservers.net --send-keys xxxxxxxx

其中xxxxxxxx爲你的公鑰idhtml

查看是否發佈成功

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys xxxxxxxx

配置maven

~/.m2/settings.xmljava

<settings>
    <servers>
        <server>
            <id>oss</id>
            <username>用戶名</username>
            <password>密碼</password>
        </server>
    </servers>
</settings>

配置項目pom.xml

<issueManagement>
        <system>Github Issue</system>
        <url>https://github.com/xxx/xxx-xxx/issues</url>
    </issueManagement>

    <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>xxx</name>
            <email>xxx@gmail.com</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git@github.com:xxx/xxx-xxx.git</connection>
        <developerConnection>scm:git@github.com:xxx/xxx-xxx.git</developerConnection>
        <url>git@github.com:xxx/xxx-xxx.git</url>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.4</version>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <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>
            <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.10.4</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Gpg Signature -->
                    <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>
                </plugins>
            </build>
        </profile>
    </profiles>

發佈

mvn clean deploy -P release -Dgpg.passphrase=xxxx

倉庫查看

https://oss.sonatype.org/cont...git

doc


想獲取最新內容,請關注微信公衆號spring

圖片描述

相關文章
相關標籤/搜索