gradle关于 Maven Publish Plugin文档
详细的配置信息可参照文档
测试使用gralde版本 gradle-6.3-all.zip
-
找一个公用的git仓库 新建一个repo 本地初始化一个git仓库并关联到刚申请的远程仓库地址
-
gradle 发布简单配置
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
url = "D:/open_repos/mvns" //如果直接配远程仓库的地址 会在发布的时候
//404 没仔细找原因 指定的文件夹为刚本地建的git repo
}
}
}
运行打包命令
gradle :{projectName}:publishMavenPublicationToMavenRepository
其中publish后面的maven是task名字 要与在gradle中的配置一致
原文描述如下
The Maven Publish Plugin makes this easy to do by automatically creating a PublishToMavenLocal task for each MavenPublication in the publishing.publications container. The task name follows the pattern of publishPubNamePublicationToMavenLocal
执行gradle的pusblish任务后即可在本地的repo中看到相应的包 之后把仓库中的内容推到远程即可
引入时(以码云为例)
https://gitee.com/${yourName}/${repoName}/raw/master