密鑰生成以後把你的公鑰須要上傳到公鑰服務器,公鑰服務器之間會自動同步java
<server> <!-- https://issues.sonatype.org/secure/Dashboard.jspa --> <id>ossrh</id> <username>你的Sonatype帳戶</username> <password>你的Sonatype密碼</password> </server>
<profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg.exe</gpg.executable> <gpg.passphrase>GPG私鑰密碼</gpg.passphrase> </properties> </profile>
根據中央倉庫發佈要求(見參考),pom中須要提供必要的項目信息,如下元素缺一不可,不然沒法發佈:git
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.github.rockswang</groupId> <artifactId>java-curl</artifactId> <version>1.2.0</version> <packaging>jar</packaging> <parent> <groupId>org.sonatype.oss</groupId> <artifactId>oss-parent</artifactId> <version>7</version> </parent> <name>java-curl</name> <description>Ultra-lightweight CURL implementation in pure java 1.6</description> <url>https://github.com/rockswang/java-curl</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <!--Compiler--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <!-- 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.9.1</version> <configuration> <additionalparam>-Xdoclint:none</additionalparam><!-- 添加這個壓制JavaDoc檢查 --> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <!-- GPG mvn clean deploy -P release -Dgpg.passphrase=YourPassphase --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <licenses> <license> <name>The Apache Software License, Version 2.0</name> <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo,manual</distribution> </license> </licenses> <developers> <developer> <name>Rocks Wang</name> <email>rockswang@foxmail.com</email> <organization>roxstudio</organization> <url>https://github.com/rockswang</url> </developer> </developers> <scm> <connection>scm:git:https://github.com/rockswang/java-curl.git</connection> <developerConnection>scm:git:https://github.com/rockswang/java-curl.git</developerConnection> <url>https://github.com/rockswang/java-curl</url> <tag>1.2.0</tag> </scm> <distributionManagement> <snapshotRepository> <id>ossrh</id> <name>OSS Snapshots Repository</name> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>ossrh</id> <name>OSS Staging Repository</name> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> </project>
別人的流程:https://blog.csdn.net/liuhuan...
別人踩的坑:https://blog.csdn.net/h324321...
GPG密鑰的生成與使用 https://www.jianshu.com/p/7f1...
中央倉庫發佈要求:https://central.sonatype.org/...github