问题描述
我是Gradle和Artifactory的新手,我想上传一个jar文件给Artifactory。
这里是我的build.gradle文件。
I am a newbie to Gradle and Artifactory and I want to upload a jar file to Artifactory.Here is my build.gradle file.
apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'maven' apply plugin: 'artifactory-publish' groupId = 'myGroup' version = '1.0' def artifactId = projectDir.name def versionNumber = version artifactory { contextUrl = 'http://path.to.artifactory' // base artifactory url publish { repository { repoKey = 'libs-releases' //The Artifactory repository key to publish to username = 'publisher' //The publisher user name password = '********' //The publisher password maven = true } } } artifactoryPublish { dependsOn jar }
运行artifactoryPublish任务后,构建成功如下。 / p>
After running the artifactoryPublish task, the build is successful as below.
> gradle artifactoryPublish --stacktrace :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar :artifactoryPublish Deploying build info to: http://path.to.artifactory/api/build BUILD SUCCESSFUL Total time: 7.387 secs
然而,除了构建信息之外,没有任何内容发送给Artifactory。
However, there is nothing sent to Artifactory except the build info.
任何帮助将不胜感激
Tuncay
编辑
正如JBaruch提到的,我已经添加了
As JBaruch mentioned, I've added
apply plugin: 'maven-publish' publishing { publications { mavenJava(MavenPublication) { from components.java } } }
和缺省部分到artifactory任务
and defaults section to artifactory task
defaults { publications ('mavenJava') }
现在它可以工作。
谢谢
Thanks
推荐答案
这是因为您没有任何出版物。 适用于并上传。
That's because you don't have any publications. The artifactory-publish plugin works with maven-publish plugin and uploads publications.
如果您喜欢使用,您需要,而不是 artifactory-publish 。
If you prefer working with the old maven plugin, you need artifactory plugin, not artifactory-publish.
官方文档中的。
这篇关于使用gradle将artifact上传到artifactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!