gradle 上传jar包_gradle 如何将 jar 包等文件上传到 nexus maven 仓库

通过 gradle 构建的项目,想把 jar 包发布到 nexus maven 仓库,只需要在 build.gradle 配置中加入 uploadArchives 构件信息即可,具体操作方法如下说明。

配置信息

在项目对应的 build.gradle 中添加如下信息:

# maven 插件,必须有

apply plugin: 'maven'

# 若想把源码一起打包,需要添加该插件

apply plugin: "maven-publish"

# maven 坐标相关的内容(group、version、name)

group = 'com.xxx.xxx'

version = '0.1-SNAPSHOT'

jar {

baseName = 'xxx-xxxx-xxxxx'

}

# 上传文件的构件

uploadArchives {

repositories {

mavenDeployer {

# snapshot 仓库路径,主要是存放开发阶段的相关文件

snapshotRepository(url: 'http://xxx/repository/maven-snapshots/') {

authentication(userName: 'xxxx', password: 'xxxxx')

}

# 发布包仓库路径,主要是正式(release)包的发布

repository(url: 'http://xxx/repository/maven-releases/') {

authentication(userName: 'xxxx', password: 'xxxxx')

}

}

}

}

如果使用的是 IDEA,会在最右边的 gradle 插件里发现 uploadArchives 选项,点击其即可,如下图:

704fb4e66fcd87ef4690f75c8fe94707.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值