我是Gradle和Artifactory的新手,我想將jar文件上傳到Artifactory。 這是我的build.gradle文件。使用gradle將神器上傳到artifactory
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任務後,構建成功,如下所示。
> 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')
}
現在,它的工作。
感謝
感謝您提供非常有幫助的問題和更新。一個註釋幫助了我:'defaults'實際上進入'artifactory.publish'內部,而不僅僅是在根'artifactory'任務中。 –
我在博客中總結了這一點:http://buransky.com/scala/publish-jar-artifact-using-gradle-to-artifactory/ –
當我嘗試它時:'錯誤:(x,0)可能在SoftwareComponentInternal set上找不到屬性'java'。你能發佈完整的腳本嗎? –