日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

向maven中央仓库提交jar

發布時間:2025/3/14 编程问答 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 向maven中央仓库提交jar 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

從來都是從中央倉庫下載jar,這次需要向中央倉庫提交jar, 利用Sonatype OSSRH可以把jar等資源提交給Maven的中央倉庫。

Sonatype OSSRH介紹:

Sonatype OSSRH使用Nexus?為開源項目提供倉庫管理服務,該倉庫就是所謂maven的中央倉庫,OSSRH允許我們向Maven中央倉庫提交二進制文件。

1:提交(deploy)開發版本的二進制文件(snapshorts)

2: 階段性的發布版本

3:發布一個release,然后同步他們到中央倉庫。

初始階段

1:注冊一個JIRA賬號:https://issues.sonatype.org/secure/Signup!default.jspa

2:創建一個新工程的單:https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

只有當這個jira單的狀態我resolved時,才可以提交jar包

審查要求

1:提供javadoc和source

2: 使用gpg或者pgp對文件進行簽名

3: pom.xml文件

4:正確的坐標:groupId,artifactId,version

<groupId>com.sequoiadb</groupId><artifactId>sequoiadb-driver</artifactId><version>1.12</version>

5: projectName,description,url等。

<name>${project.groupId}:${project.artifactId}</name><description>SequoiaDB Driver Library</description><url>https://github.com/SequoiaDB/SequoiaDB</url>

6: license 信息

<licenses><license><name>The Apache License, Version 2.0</name><url>http://www.apache.org/licenses/LICENSE-2.0.txt</url></license></licenses>

7 : 開發者信息

<developers><developer><name>linyoubing</name><email>linyoubing@sequoiadb.com</email><organization>sequoiadb</organization><organizationUrl>http://www.sequoiadb.com</organizationUrl></developer></developers>

8: SCM信息

<scm><connection>scm:git:https://github.com/SequoiaDB/SequoiaDB.git</connection><developerConnection>scm:git:https://github.com/SequoiaDB/SequoiaDB.git</developerConnection><url>https://github.com/SequoiaDB/SequoiaDB</url><tag>v1.12</tag></scm>

?

部署

可以使用多種方式部署,這是使用maven的方式

1:分布管理和認證:

我使用了maven部署插件,所以pom.xml中加入:

<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>

需要在maven_home/conf/settings.xml配置jira的賬號和密碼

<settings><servers><server><id>ossrh</id><username>your-jira-id</username><password>your-jira-pwd</password></server></servers> </settings>

2:配置生成javadoc和sources包的插件:

<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><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>

3:GPG自動簽名的插件:

<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>

在settings.xml中配置gpg的簽名 :(需要先用gpg來生成)

<settings><profiles><profile><id>ossrh</id><activation><activeByDefault>true</activeByDefault></activation><properties><gpg.executable>gpg2</gpg.executable><gpg.passphrase>the_pass_phrase</gpg.passphrase></properties></profile></profiles> </settings>

4: 使用Profile

應該javadoc和source的jar包生成也需要使用gpg來簽名,所以很浪費時間,而且這些執行通常都獨立于標準構建流程,所以把他們移動到一個profile.

<profiles><profile> <id>release</id><build><plugins><plugin><groupId>org.sonatype.plugins</groupId><artifactId>nexus-staging-maven-plugin</artifactId><version>1.6.3</version><extensions>true</extensions><configuration><serverId>ossrh</serverId><nexusUrl>https://oss.sonatype.org/</nexusUrl><autoReleaseAfterClose>true</autoReleaseAfterClose></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-release-plugin</artifactId><version>2.5</version><configuration><autoVersionSubmodules>true</autoVersionSubmodules><useReleaseProfile>false</useReleaseProfile><releaseProfiles>release</releaseProfiles><goals>deploy</goals></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.0</version><configuration><source>1.6</source><target>1.6</target></configuration></plugin><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><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><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>2.9</version><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin></plugins></build></profile> </profiles>

提交一個snapshot版本:

1:修改version加一個-SNAPSHOT, 執行 mvn clean deploy

發布一個release版本

1:修改version 不要加-SNAPSHOT, ?可以手動修改,也可以執行?

mvn versions:set -DnewVersion=1.2.3

2: 執行 mvn clean deploy -P release

轉載于:https://www.cnblogs.com/gaoxing/p/4359795.html

總結

以上是生活随笔為你收集整理的向maven中央仓库提交jar的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。