Sonatype注册账号
- https://issues.sonatype.org/secure/Signup!default.jspa
- https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
配置maven
settings.xml
<servers>
<server>
<id>snapshot</id>
<username>Sonatype用户名</username>
<password>Sonatype密码</password>
</server>
<server>
<id>release</id>
<username>Sonatype用户名</username>
<password>Sonatype密码</password>
</server>
</servers>
创建gpg key
https://maven.apache.org/developers/release/pmc-gpg-keys.html
gpg --gen-key
设置名字
设置邮箱
设置密码
查看key
gpg --list-secret-keys
gpg -K
发送key到Ubuntu服务器
gpg --send-keys --keyserver keyserver.ubuntu.com <KEY ID>
maven项目pom.xml
https://github.com/spark2fire/alberti/blob/master/pom.xml
<profiles>
<profile>
<id>release</id>
<distributionManagement>
<snapshotRepository>
<id>snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>release</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>release</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
<execution>
<id>snapshot</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>dokka-maven-plugin</artifactId>
<version>${dokka.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
<configuration>
<dokkaPlugins>
<plugin>
<groupId>org.jetbrains.dokka</groupId>
<artifactId>kotlin-as-java-plugin</artifactId>
<version>${dokka.version}</version>
</plugin>
</dokkaPlugins>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>release</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>release</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
发布到maven仓库
mvn deploy -Prelease