内容简介:建议使用maven中央仓库进行发布,不过我嫌步骤太繁琐了,还需要审核,所以才用github来做。发布中央仓库的可以参考使用github分两种,一种是两种方案都需要在github创建相应的repo,具体创建步骤不多说,自行百度。
建议使用maven中央仓库进行发布,不过我嫌步骤太繁琐了,还需要审核,所以才用github来做。发布中央仓库的可以参考 Maven 发布自己的项目到 Maven 中央仓库
使用github分两种,一种是 mvn install
或者 deploy
到本地路径,然 后git add && commit && push
,一种是 maven-plugins
两种方案都需要在github创建相应的repo,具体创建步骤不多说,自行百度。
1. maven-plugins
参考 stackoverflow.com/a/14013645
1.修改 ~/.m2/settings.xml
<!-- NOTE: MAKE SURE THAT settings.xml IS NOT WORLD READABLE! --> <settings> <servers> <server> <id>github</id> <username>YOUR-USERNAME</username> <password>YOUR-PASSWORD</password> </server> </servers> </settings> 复制代码
2.修改pom.xml
<properties> <!-- github server corresponds to entry in ~/.m2/settings.xml --> <github.global.server>github</github.global.server> </properties> <distributionManagement> <repository> <id>internal.repo</id> <name>Temporary Staging Repository</name> <url>file://${project.build.directory}/mvn-repo</url> </repository> </distributionManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> <configuration> <altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo</altDeploymentRepository> </configuration> </plugin> </plugins> </build> 复制代码
3.修改pom.xml,配置maven-plugins
<build> <plugins> <plugin> <groupId>com.github.github</groupId> <artifactId>site-maven-plugin</artifactId> <version>0.12</version> <configuration> <message>Maven artifacts for ${project.version}</message> <!-- git commit message --> <noJekyll>true</noJekyll> <!-- disable webpage processing --> <outputDirectory>${project.build.directory}/mvn-repo</outputDirectory> <!-- matches distribution management repository url above --> <branch>refs/heads/master</branch> <!-- remote branch name --> <includes><include>**/*</include></includes> <repositoryName>YOUR-REPOSITORY-NAME</repositoryName> <!-- github repo name --> <repositoryOwner>YOUR-GITHUB-USERNAME</repositoryOwner> <!-- github username --> <force>false</force> <!-- force commit or no --> <merge>true</merge> <!-- merge or no --> </configuration> <executions> <!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase --> <execution> <goals> <goal>site</goal> </goals> <phase>deploy</phase> </execution> </executions> </plugin> </plugins> </build> 复制代码
4.提交到github
mvn clean deploy 复制代码
2. mvn deploy && git add && commit && push
1.clone github repo
git clone https://github.com/YOUR-USERNAME/YOUR-PROJECT-NAME /home/my/code/maven-repo/ 复制代码
2.命令行执行mvn deploy
mvn deploy -DaltDeploymentRepository=my-mvn-repo::default::file:/home/my/code/maven-repo/ 复制代码
3.push到github
cd /home/my/code/maven-repo/ git add . git commit -m 'Maven artifacts for 0.0.1' git push -u origin master 复制代码
3. 在项目中使用github repo
<repositories> <repository> <id>YOUR-PROJECT-NAME-mvn-repo</id> <url>https://raw.githubusercontent.com/YOUR-USERNAME/YOUR-PROJECT-NAME/master/</url> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> 复制代码
以上所述就是小编给大家介绍的《使用github搭建自己的maven库》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Head First Mobile Web
Lyza Danger Gardner、Jason Grigsby / O'Reilly Media / 2011-12 / $ 50.84
Despite the huge number of mobile devices and apps in use today, your business still needs a website. You just need it to be mobile. Head First Mobile Web walks you through the process of making a con......一起来看看 《Head First Mobile Web》 这本书的介绍吧!