我是 Gradle 和 Artifactory 的新手,我想将 JAR 文件上传到 Artifactory。
这是我的 build.gradle
文件:
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' // Artifactory repository key to publish to
username = 'publisher' // publisher user name
password = '********' // publisher password
maven = true
}
}
}
artifactoryPublish {
dependsOn jar
}
运行artifactoryPublish
任务后,构建成功,如下所示:
> 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。
任何帮助将不胜感激。
编辑:
正如 JBaruch 提到的,我添加了以下内容:
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
并将默认部分设置为 Artifactory 任务:
defaults {
publications ('mavenJava')
}
现在可以了。
谢谢。
最佳答案
那是因为您没有任何出版物
。 artifactory-publish
plugin与maven-publish
plugin一起工作并上传publications
.
如果您更喜欢使用the old maven plugin ,您需要artifactory
plugin ,而不是artifactory-publish
。
关于gradle - 使用 Gradle 将 Artifactory 上传到 Artifactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22352475/