发布jar包到远端github仓库使用(将github仓库当作maven仓库)

2年前 (2022) 程序员胖胖胖虎阿
128 0 0

今天把单点登陆的core模块搬到了github仓库 并且利用github仓库作为maven仓库 在项目中进行了引用

1. 起初看技术博客没有完全引入进来,调整了一下OK了

2. 还可以将其他模块或者工具类,常用的类,自己用的类发布到GitHub仓库 作为maven依赖

 

maven部署的插件,部署本地:

<!--github上传插件,用于修改后的发布,执行mvn clean deploy自动打包上传到github-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <altDeploymentRepository>internal.repo::default::file://${repository.directory}/web-sso-core</altDeploymentRepository>
                </configuration>
            </plugin>

 

使用mvn clean deploy命令部署

部署到远端github仓库的插件:

        <plugin>
                <groupId>com.github.github</groupId>
                <artifactId>site-maven-plugin</artifactId>
                <version>0.12</version>
                <configuration>
                    <message>Maven artifacts for ${project.artifactId}-${project.version}</message>
                    <noJekyll>true</noJekyll>
                    <outputDirectory>${repository.directory}/web-sso-core</outputDirectory>
                    <branch>refs/heads/master</branch>
                    <merge>true</merge>
                    <includes>
                        <include>**/*</include>
                    </includes>
                    <repositoryName>web-sso-core</repositoryName>
                    <repositoryOwner>deadzq</repositoryOwner>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>site</goal>
                        </goals>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>

同样是使用mvn clean deploy.

配置文件,repository.directory是项目的根路径,在另一个地方指定模块的文件夹名: 如上面的插件的web-sso-core

<properties>
        <java.version>1.8</java.version>
        <jedis.version>3.0.0</jedis.version>
        <github.global.server>github</github.global.server>
        <repository.directory>C:\Users\ukyo\Documents\</repository.directory>
    </properties>

需要开放本地maven仓库的,设定用户名密码:

settings.xml:

server标签:

<server>
      <id>github</id>
      <username>yourgithubloginname</username>
      <password>yourpassword</password>
    </server>

注意整个配置中的id应该相同.

 

另一边,在项目中去使用时,需要配置github仓库: 二级标签 (一级标签project)

<repositories>
        <repository>
            <id>github</id>
            <url>https://raw.github.com/deadzq/web-sso-core/master</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>

其中里面的url获取方式为,找到你发布好的github的模块,前面加二级域名raw. 后面加 /master ,假如你是发布到master分支的话.

 

最后加入这个模块即可:

<dependency>
            <groupId>com.sso</groupId>
            <artifactId>web-sso-core</artifactId>
            <version>1.0.0</version>
        </dependency>

正常引入:

发布jar包到远端github仓库使用(将github仓库当作maven仓库)

 

其他资料:

实测Maven上传jar包到私服的方法归纳

相关文章

暂无评论

暂无评论...