gradle 上传jar包,Gradle:如何将自定义JAR文件上传到Maven存储库

I build a jar file without using Gradle Jar task (I need to be using Ant task for that inside my task). How do I configure uploadArchives to be able to install JAR in specified repository.

I have tried to override default artifact with

uploadArchives {

repositories {

mavenDeployer {

// some Maven configuration

}

}

}

artifacts {

archives file: file('bin/result.jar')

}

but I'm getting an error that there may not be 2 artifacts with the same type and classifier, which means this configuration adds rather that overrides configuration.

解决方案

You are right, artifacts closure can only add artifacts to the given configuration (see ArtifactHandler API).

You have two options:

1) Add an artifact filter as described here (see ch. 45.6.4.1. "Multiple artifacts per project"). If you use this, try declaring your archives configuration like:

artifacts {

archives file: file('bin/result.jar'), name: 'result', type: 'jar'

}

This way, you something like this in your artifact filter:

addFilter('result') {artifact, file ->

artifact.name == 'result'

}

2) Upload it as a separate maven module. If result.jar is the only jar you are uploading this may be a good solution.

configurations {

resultArchives

}

uploadResultArchives {

repositories {

mavenDeployer {

repository(url: "same/url/here")

}

}

}

artifacts{

resultArchives file: file('bin/result.jar')

}

Hope this helps.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值