Release jar package to central warehouse

Keywords: Programming Maven Apache github git

1. Register sonatype and submit issue work order (you can find online tutorial by yourself)

2. Install gpg and create public key and private key gpg -- Gen key (you can find the tutorial on the Internet)

3. Send the key corresponding to the public key to the server (xxxx) secret key (the tutorial can be found on the Internet)

gpg --keyserver hkp://pool.sks-keyservers.net:11371 --send-keys xxxx
gpg --keyserver keyserver.ubuntu.com --send-keys xxxx
gpg --keyserver pgp.mit.edu --send-keys xxxx
gpg --keyserver keys.gnupg.net --send-keys xxxx

4. Add the following xml configuration in pom

<url>https://github.com/fashionbrot/mars-config</url>
    <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>master</tag>
        <url>scm:git:https://github.com/fashionbrot/mars-config.git</url>
        <connection>scm:git:https://github.com/fashionbrot/mars-config.git</connection>
        <developerConnection>https://github.com/fashionbrot/mars-config</developerConnection>
    </scm>
    <developers>
        <developer>
            <name>fashionbrot</name>
            <email>fashionbrot@163.com</email>
            <organization>github</organization>
        </developer>
    </developers>

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


    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.3.4.RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.12</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.19</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.58</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.github.fashionbrot</groupId>
            <artifactId>mars-ribbon</artifactId>
            <version>0.1.1</version>
        </dependency>

    </dependencies>


    <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>
                <version>3.0.0</version>
                <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='Secret key password'perhaps-Darguments='gpg.passphrase=Secret key password' -->
                </executions>
            </plugin>
        </plugins>
    </build>

5. mvn clean package

6. Enter the command mvn - Dmaven.test.skip=true verify -Dgpg.passphrase = secret key password (generate the password of public and private keys)

Then generate the following files

7. Enter the central warehouse background

8. Upload the above packed jar and encrypted files here and show that the upload is successful

9. Click publish here to Search the jar uploaded to the central warehouse in Search (it can be used in idea pom in a few minutes, and it can be viewed in the central warehouse until tomorrow)

Posted by ddrummond on Sun, 12 Apr 2020 09:08:13 -0700