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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

在github上托管Maven存储库(包含源代码和javadoc)

發布時間:2023/12/3 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在github上托管Maven存储库(包含源代码和javadoc) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如何通過maven將小型開源庫提供給其他開發人員? 一種方法是將其部署在Maven Central Repository上 。 我想要做的是將其部署到github ,因此我可以自由地對其進行修改。 這篇文章將告訴您如何做到這一點。

我將工件部署到github的典型方法是使用mvn deploy 。 步驟如下:

  • 使用site-maven-plugin將工件推送到github
  • 使用maven-javadoc-plugin推送Javadoc
  • 使用maven-source-plugin推送源
  • 配置Maven以將遠程mvn-repo用作Maven存儲庫

配置Maven部署插件

首先,我添加以下代碼片段以告知Maven將工件部署到目標目錄內的臨時位置:

<distributionManagement><repository><id>internal.repo</id><name>Temporary Staging Repository</name><url>file://${project.build.directory}/mvn-repo</url></repository> </distributionManagement> <plugins><plugin><artifactId>maven-deploy-plugin</artifactId><version>2.8.1</version><configuration><altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository></configuration></plugin> </plugins>

配置Maven

然后,我將我的github.com身份驗證信息添加到~/.m2/settings.xml以便github site-maven-plugin可以將其推送到github:

<settings><servers><server><id>github</id><password>OAUTH2TOKEN</password></server></servers> </settings>

要么

<settings><servers><server><id>github</id><username>GitHubLogin</username><password>GitHubPassw0rd</password></server></servers> </settings>

就我個人而言,我更喜歡第一種方法,因為它更安全(無需明確顯示密碼)。 要獲取github項目的OAUTH2TOKEN ,請轉到settings --> Applications --> Genreate new token

配置site-maven-plugin

配置site-maven-plugin從我的臨時位置上傳到github上的mvn-repo分支:

<plugin><groupId>com.github.github</groupId><artifactId>site-maven-plugin</artifactId><version>0.9</version><configuration><message>Maven artifacts for ${project.version}</message><noJekyll>true</noJekyll><outputDirectory>${project.build.directory}/mvn-repo</outputDirectory><branch>refs/heads/mvn-repo</branch><includes><include>**/*</include></includes><repositoryName>pengyifan-commons</repositoryName><repositoryOwner>yfpeng</repositoryOwner><server>github</server></configuration><executions><execution><goals><goal>site</goal></goals><phase>deploy</phase></execution></executions> </plugin>

寫這篇文章時,存在0.9版site-maven-plugin 。 要解決此問題,請git clone 0.10-SNAPSHOT版本,并手動mvn install 。

配置maven-source-plugin

要將源代碼包添加到mvn-repo中,我們需要配置maven-source-plugin 。 在pom.xml添加以下代碼:

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>2.3</version><executions><execution><id>attach-sources</id><goals><goal>jar</goal></goals></execution></executions> </plugin>

配置Maven-javadoc-plugin

要將java doc軟件包添加到mvn-repo中,我們需要配置maven-javadoc-plugin 。 在pom.xml添加以下代碼:

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions> </plugin>

現在運行mvn clean deploy 。 我看到maven-deploy-plugin將文件“上傳”到目標目錄中的本地暫存庫中,然后site-maven-plugin提交這些文件并將其推送到服務器。

要驗證所有二進制文件是否存在,請在瀏覽器中訪問github ,然后選擇mvn-repo分支。

配置Maven以將遠程mvn-repo用作Maven存儲庫

我們應該采取的另一步驟是配置任何poms以知道我們的存儲庫在哪里。 我們可以將以下代碼段添加到任何項目的pom.xml中:

<repositories><repository><id>PROJECT-NAME-mvn-repo</id><url>https://raw.github.com/USERNAME/PROJECT-NAME/mvn-repo/</url><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository> </repositories>

翻譯自: https://www.javacodegeeks.com/2014/09/hosting-a-maven-repository-on-github-with-sources-and-javadoc.html

總結

以上是生活随笔為你收集整理的在github上托管Maven存储库(包含源代码和javadoc)的全部內容,希望文章能夠幫你解決所遇到的問題。

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