2016-08-23 57 views
1

我想用gradle + artifactory插件+ maven-publish插件將jar + pom文件部署到artifactory。Gradle artifactoryPublish不會部署.jar文件,由spring引導生成

我試着從像this其它來源的多種解決方案,我認爲春天啓動插件是打破東西(因爲它編輯的jar文件)

下面的腳本成功地上傳一個文件.pom,但不由spring-boot生成的.jar文件。我怎樣才能讓它也上傳呢?

這是我的build.gradle:

buildscript { 
    ext { 
     springBootVersion = '1.4.0.RELEASE' 
    } 
    repositories { 
     mavenCentral() 
     jcenter() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
     classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.0" 
    } 
} 
apply plugin: 'java' 
apply plugin: 'spring-boot' 
apply plugin: "com.jfrog.artifactory" 
apply plugin: 'maven-publish' 
apply from: "gradle/artifactory.gradle" 

publishing { 
    publications { 
     mavenJava(MavenPublication) { 
      components.java 
     } 
    } 
} 

jar { 
    baseName = 'BatchParser' 

} 

version = '1.0' 
sourceCompatibility = 1.8 
targetCompatibility = 1.8 

repositories { 
    mavenCentral() 
} 


dependencies { 

    compile('org.projectlombok:lombok:1.16.10') 
    ... 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

和artifactory.gradle的

artifactory { 
    contextUrl = 'url' 
    publish { 
     repository { 
      repoKey = 'libs-release-local' 
      username = 'user' 
      password = 'password' 
     } 
     defaults { 
      publications("mavenJava") 
     } 
    } 
} 

輸出:

gradlew clean build artifactoryPublish 


[buildinfo] Not using buildInfo properties file for this build.     
:clean      
:compileJava                             
:processResources 
:classes 
:findMainClass 
:jar 
:bootRepackage                           
:assemble 
:compileTestJava                 
:processTestResources UP-TO-DATE 
:testClasses 
:test               
:check 
:build 
:generatePomFileForMavenJavaPublication     
:artifactoryPublish 
Deploying artifact: http://url/libs-release-local/BatchParser/1.0/BatchParser-1.0.pom 
Deploying build descriptor to: http://url/api/build 
Build successfully deployed. Browse it in Artifactory under http://url/webapp/builds/BatchParser/1471949957594 
+0

您要求Gradle運行哪些任務以及嘗試發佈時實際運行哪些任務? –

+0

我已經添加了命令+輸出 –

回答

3

有你publishing塊一個非常微妙的錯誤。 from缺失,導致Gradle默默不在發佈中包含jar文件。你需要使它看起來像這樣更新您的publishing塊:

publications { 
    mavenJava(MavenPublication) { 
     from components.java 
    } 
} 

如果我是你,我會打開一個搖籃可用性錯誤這一點。默默無所事事不是非常人性化。

+0

哦,這真的是不友好的。感謝您注意到我的錯誤! –

+0

有趣。在springboot添加內容之前,我會看到該jar的發佈。建議使用uploadArchives + mavenDeployer。你有這些一起工作嗎? –

+0

我們打破了構建和artifactoryPublish發佈到我們jenkins文件中的兩個單獨的gradle調用。這導致重新制作沒有彈簧靴的罐子。一個調用與構建... artifactoryPublish,並沒有問題 –