Gradle artifactoryPublish won't deploy .jar file generated by spring boot

这一生的挚爱 提交于 2019-12-14 03:52:42

问题


I'm trying to deploy a jar + pom file to artifactory using gradle + artifactory plugin + maven-publish plugin.

I've tried multiple solutions from other sources like this and I think the spring-boot plugin is breaking stuff (because it edits the jar file)

The following script successfully uploads a .pom file, but not the .jar file generated by spring-boot. How can I get it to also upload that?

this is my 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')
}

and artifactory.gradle

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

output of:

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

回答1:


There's a very subtle mistake in your publishing block. from is missing which is causing Gradle to silently not include the jar file in the publication. You need to update your publishing block so that it looks like this:

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

If I were you, I'd open a Gradle usability bug for this. Silently doing nothing isn't very user friendly.



来源:https://stackoverflow.com/questions/39097992/gradle-artifactorypublish-wont-deploy-jar-file-generated-by-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!