关于GitHub的骚操作一直以来都有很多,这篇文章记录一下使用GitHub来做免费maven 私服的方法。
发布到GitHub
修改setting.xml
修改maven
的setting.xml
文件,在servers
节点下添加
<server>
<id>github</id>
<username>yourname</username>
<password>yourpassword</password>
</server>
使用maven插件
修改项目工程的pom.xml
文件,添加以下两个插件:
maven-deploy-plugin
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>
internal.repo::default::file://${project.build.directory}/maven-repo
</altDeploymentRepository>
</configuration>
</plugin>
site-maven-plugin
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.12</version>
<configuration>
<message>🐳 deploy maven artifacts, version: ${project.version}</message>
<noJekyll>true</noJekyll>
<outputDirectory>${project.build.directory}/maven-repo</outputDirectory>
<!--本地jar地址-->
<branch>refs/heads/master</branch><!--分支的名称-->
<merge>true</merge>
<includes>
<include>**/*</include>
</includes>
<repositoryName>maven-repo</repositoryName><!--对应github上创建的仓库名称 name-->
<repositoryOwner>cayzlh</repositoryOwner><!--github 仓库所有者即登录用户名-->
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
###deploy
执行命令进行打包:
mvn clean package
好像可以不用打包
在idea
左侧lifecycle
中双击deploy
:
静静等待…..
使用
在需要使用到私服的项目pom.xml
文件中添加:
<repositories>
<repository>
<id>maven-repo</id>
<url>https://raw.githubusercontent.com/yourname/maven-repo/master/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Enjoy it.

相关推荐
版权声明
- 本文链接: https://www.cayzlh.com/2018/06/02/cfd298ed.html
- 版权声明: 文章内容仅用作学习和分享,如有雷同,纯属拷贝。
留言区