我是 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
}
}
}
并将部分默认为人工任务:
defaults {
publications ('mavenJava')
}
现在它起作用了。
谢谢。