向maven中央仓库提交jar
從來都是從中央倉庫下載jar,這次需要向中央倉庫提交jar, 利用Sonatype OSSRH可以把jar等資源提交給Maven的中央倉庫。
Sonatype OSSRH介紹:
Sonatype OSSRH使用Nexus?為開源項目提供倉庫管理服務(wù),該倉庫就是所謂maven的中央倉庫,OSSRH允許我們向Maven中央倉庫提交二進(jìn)制文件。
1:提交(deploy)開發(fā)版本的二進(jìn)制文件(snapshorts)
2: 階段性的發(fā)布版本
3:發(fā)布一個release,然后同步他們到中央倉庫。
初始階段
1:注冊一個JIRA賬號:https://issues.sonatype.org/secure/Signup!default.jspa
2:創(chuàng)建一個新工程的單:https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
只有當(dāng)這個jira單的狀態(tài)我resolved時,才可以提交jar包
審查要求
1:提供javadoc和source
2: 使用gpg或者pgp對文件進(jìn)行簽名
3: pom.xml文件
4:正確的坐標(biāo):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 : 開發(fā)者信息
<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:分布管理和認(rèn)證:
我使用了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
應(yīng)該javadoc和source的jar包生成也需要使用gpg來簽名,所以很浪費時間,而且這些執(zhí)行通常都獨立于標(biāo)準(zhǔn)構(gòu)建流程,所以把他們移動到一個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, 執(zhí)行 mvn clean deploy
發(fā)布一個release版本
1:修改version 不要加-SNAPSHOT, ?可以手動修改,也可以執(zhí)行?
mvn versions:set -DnewVersion=1.2.32: 執(zhí)行 mvn clean deploy -P release
轉(zhuǎn)載于:https://www.cnblogs.com/gaoxing/p/4359795.html
總結(jié)
以上是生活随笔為你收集整理的向maven中央仓库提交jar的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opengl环境配置
- 下一篇: Mvc 自带分页控件PagedList.