­

Maven中央仓库发布历程

  • 2019 年 10 月 3 日
  • 筆記

????

???????Spring boot??????????? multithreadpool-spring-boot-starter???????????????????????????????????????????????????maven????????????????????????????

????????????????????????????????????????????????????????

??????????????????????????

 

??????

1> mac osx 10.14.6 : ?????mac????

2> Apache Maven 3.2.3 : ??????maven????????????

 

??????

1?????

1> ??sonatype????? https://issues.sonatype.org ??????????????????????????

2> ??????issue??????? Community Support – Open Source Project Repository Hosting

 

3>  ?????????Group Id?????????????????????????????????????????????????10?????????????????????:

  • ?????? group id????????
  • ??????????????github?????????github??????issue???????????????????

????????issue???????????issue?????????: sonatype-issue ? Github??

4> ?????????????sonatype???????maven??????snapshot???release?????????????????issue?????issue

 

2?gpg ????

gpg???????????????????????????

1> ?????https://www.gnupg.org/download/

2> ????????????

3> ????????????????????????????????? (PS: ???????????????????)

gpg2 --gen-key 

 4> ????????, ???????????????

$ gpg2 --list-keys 
...

  pub rsa2048 2019-04-12 [SC] [????2021-04-11]
  9A1640F7A2551131612D51B12D83594B7B29D86A
  uid [ ?? ] xiaoxuetu <xiaoxuetu@163.com>
  sub rsa2048 2019-04-12 [E] [????2021-04-11]

5> ????????????????

$ gpg --keyserver hkp://subkeys.pgp.net --send-keys 9A1640F7A2551131612D51B12D83594B7B29D86A  ...  gpg: ?????? 2D83594B7B29D86A ? hkp://subkeys.pgp.net  gpg: ???????????Server indicated a failure  gpg: ???????????Server indicated a failure

6> ????????????????????????????? 2D83594B7B29D86A

$ gpg --keyserver hkp://subkeys.pgp.net --send-keys 2D83594B7B29D86A

  gpg: sending key 2D83594B7B29D86A to hkp://pool.sks-keyservers.net

 

 

3?Maven????

??????maven??????? ${HOME}/.m2/setting.xml ??????????????? ${MAVEN_HOME}/conf/setting.xml ????? ${HOME}/.m2 ??????????

1> ?????????

    <server>        <id>sonatype_releases</id>        <username>your user name</username>        <password>your password</password>      </server>      <server>        <id>sonatype_snapshots</id>        <username>your user name</username>        <password>your password</password>      </server>

 

2> ??gpg????

<settings>    <profiles>      <profile>        <id>gpg</id>        <properties>          <!-- ?????????gpg2????gpg???????????gpg2?????? -->          <gpg.executable>gpg2</gpg.executable>          <gpg.passphrase>your password</gpg.passphrase>        </properties>      </profile>    </profiles>    <activeProfiles>      <activeProfile>gpg</activeProfile>    </activeProfiles>  </settings>

 

4???maven??

1> ????pom.xml????????????????????????????

<!-- ?????? -->      <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>          <connection>scm:git:git@github.com:xiaoxuetu/multithreadpool-spring-boot-starter.git</connection>          <developerConnection>scm:git:git@github.com:xiaoxuetu/multithreadpool-spring-boot-starter.git          </developerConnection>          <url>http://github.com/xiaoxuetu/multithreadpool-spring-boot-starter/tree/master</url>      </scm>          <!-- ?????? -->      <developers>          <developer>              <name>xiaoxuetu</name>              <email>xiaoxuetu@163.com</email>              <organization>https://github.com/xiaoxuetu</organization>              <timezone>+8</timezone>          </developer>      </developers>        <!-- ?????? -->      <distributionManagement>          <repository>              <!-- ???id??????????release id ?? -->              <id>sonatype_releases</id>              <name>Nexus Release Repository</name>              <!-- ???????issue?????????release????-->              <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>          </repository>          <snapshotRepository>              <!-- ???id??????????snapshot id ?? -->              <id>sonatype_snapshots</id>              <name>Nexus Snapshot Repository</name>              <!-- ???????issue?????????snapshot????-->              <url>https://oss.sonatype.org/content/repositories/snapshots</url>          </snapshotRepository>      </distributionManagement>

 

2> ?????maven????????????jar?????????????Javadoc?source?asc(??gpg?????)??????maven?????????

    <build>          <plugins>              <plugin>                  <groupId>org.sonatype.plugins</groupId>                  <artifactId>nexus-staging-maven-plugin</artifactId>                  <version>1.6.7</version>                  <extensions>true</extensions>                  <configuration>                      <!-- ???id??????????release id ?? -->                      <serverId>sonatype_releases</serverId>                      <nexusUrl>https://oss.sonatype.org/</nexusUrl>                      <!-- ???????????close?release??????????true -->                      <autoReleaseAfterClose>false</autoReleaseAfterClose>                  </configuration>              </plugin>                <!-- ??java source.jar -->              <plugin>                  <groupId>org.apache.maven.plugins</groupId>                  <artifactId>maven-source-plugin</artifactId>                  <version>2.2.1</version>                  <executions>                      <execution>                          <id>attach-sources</id>                          <goals>                              <goal>jar-no-fork</goal>                          </goals>                      </execution>                  </executions>              </plugin>                <!-- ??asc ???? -->              <plugin>                  <groupId>org.apache.maven.plugins</groupId>                  <artifactId>maven-gpg-plugin</artifactId>                  <version>1.5</version>                  <executions>                      <execution>                          <!-- ???????gpg??id?? -->                          <id>gpg</id>                          <phase>verify</phase>                          <goals>                              <goal>sign</goal>                          </goals>                      </execution>                  </executions>              </plugin>          </plugins>      </build>

  

5?????

1> ????????????? pom.xml ? autoReleaseAfterClose ???true?????????????close?release???????????????????????2??

 mvn clean javadoc:jar deploy -P release

 

2> ??https://oss.sonatype.org?????staging Repositories

 

3> ????????????????????Close?Release??

 

4> ??Release??????????????????????issue??? “??????????”?????2???????????????maven??

5> ??Close??Release????????????????????????????

 

??????

1> ????? Maven ????????: https://juejin.im/post/5cb03e1a5188251b0e4e3583

2> Working with PGP Signatures: https://central.sonatype.org/pages/working-with-pgp-signatures.html#distributing-your-public-key

3> Deploying to OSSRH with Apache Maven: https://central.sonatype.org/pages/apache-maven.html