Preface: open source projects
I believe, has its own open source projects is that each programmer hearts most want to achieve something, whether it is big or small projects projects. Of course, not every programmer large projects have the ability to complete; however small projects, for example, I have written Spring Boot Starter, or write your own tools, which is quite interesting, quite meaningless.
So when we write the finished project, then of course you want to own open source project to deploy the Maven central repository inside, and so that everyone can see and use to. Now I will explain in more detail how to deploy their open-source projects to Maven, hoping to help you ~
1, registered sonatype
In issues sonatype registration requirement account, password complexity little bit above, so we created a small get hold of the best books record it.
2, landing sonatype
New issue: Click the head Navigation 新建
buttons
Fill out the form: refer to the diagram
after New awaiting approval on the line, the general soon, there will be mail notification, to step back here may be performed first, if successful approval can be ignored, if the middle there is a problem, for example, like the above mentioned to group Id corresponding domain name if you as the owner, then you need to restore the line on the issue.
3, download and install gunpg
Directly in the Baidu search and download.
After installing, we open the cmd window, enter gpg --version
check whether the installation is successful, the default is to add the environment variable is no problem, if not, manually install directory under the bin
directory appended to the environment variable path
of the path.
4, create a key
Execution gpg --gen-key
, follow the prompts to enter, to enter Name & Email and so on.
Finally, you will be prompted passphrase
, and then we have to set the record, followed by the deployment of the project to the Maven central repository and will be needed.
Then displays key information input validation, of course, you can also enter the gen --list-key
command to see what keys.
5, upload key
gpg --keyserver http://pool.sks-keyservers.net:11371 --send-keys 8D2522AA90CD41AC1735DCBE52608BB84871117D
gpg --keyserver http://keyserver.ubuntu.com:11371 --send-keys 8D2522AA90CD41AC1735DCBE52608BB84871117D
gpg --keyserver http://keys.gnupg.net:11371 --send-keys 8D2522AA90CD41AC1735DCBE52608BB84871117D
The command format is:
gpg --keyserver 服务器地址 --send-keys 密钥
The above three general uploaded on it, but if not, when will prompt deployment, follow the prompts to continue to upload.
6, modify the configuration of Maven setting.xml
Add the following configuration is required.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 省略其他配置 -->
<servers>
<server>
<id>ossrh</id>
<username>sonatype账号</username>
<password>sonatype密码</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.passphrase>生成密钥时输入的passphrase</gpg.passphrase>
<!-- gpg.exe的绝对路径,在gpg安装目录下的bin目录中 -->
<gpg.executable>D:\Program Files (x86)\GnuPG\bin\gpg.exe</gpg.executable>
<!-- 上一步执行gpg --list-key命令输出的路径,一般在C:\User\当前用户\AppData\Roaming\gnupg -->
<gpg.homedir>C:\Users\Administrator\AppData\Roaming\gnupg</gpg.homedir>
</properties>
</profile>
</profiles>
</settings>
7, modify pom.xml
Reference: https://bitbucket.org/simpligility/ossrh-pipeline-demo
First, of course, modified version of the project, and no longer a band SNAPSHOT
<groupId>com.github.howinfun</groupId>
<artifactId>h2cache-spring-boot-starter</artifactId>
<version>0.0.1</version>
Increase open source license: Configure your own open source project agreement to
<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
Add information developers:
<developers>
<developer>
<name>Howinfun</name>
<!-- 邮件 -->
<email>[email protected]</email>
<!-- 开源地址 -->
<url>https://github.com/Howinfun</url>
</developer>
</developers>
Increase project Address:
<scm>
<url>https://github.com/Howinfun/h2cache-spring-boot-starter</url>
<connection>https://github.com/Howinfun/h2cache-spring-boot-starter.git</connection>
<developerConnection>https://github.com/Howinfun</developerConnection>
</scm>
Increase sonatype configuration:
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
Adding plug-ins:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</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>
</executions>
</plugin>
</plugins>
</build>
Add a configuration, problem-solving environment under JDK1.8 release occur:
<profiles>
<profile>
<id>disable-javadoc-doclint</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<properties>
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
</profiles>
8, deployment
IDEA to use the Maven modules deployed on it.
Finally, you will be prompted to build a successful ~
9, the manual release
According to the above steps, the project will be automatically released after close to sonatype, then release, but due to network delay and other reasons, it may fail, so we own manual release slightly better.
-
Open oss.sonatype and log in, switch to the
stagingRepositories
menu. -
Find their own projects, selected after clicking
close
the button to close the required time, you can wait a while back to see -
After waiting close the project is complete, select an item and click
release
the button, release takes time, and then click the Publish operation is not required, and the project will be automatically deleted after publishing is complete. -
Finally, after twelve hours we can
Maven
find their own project inside the warehouse.