3

I am using Spring-Boot to develop my new project. In my build.gradle file, I am using 'bootRepackage.classifier', so I can separately generate the default jar of my project and the executable jar that is generated using Spring Boot. I would like to publish both jars, but I am running into issues. I am using the uploadArchives task to upload my jars to a Nexus Maven repository. I can only get my default jar to upload. Here is the part of my build.gradle file that pertains to uploading the archive:

bootRepackage.classifier = 'exec'

jar {
    baseName='default'
    version = '1.0.0'
}

uploadArchives {
    repositories {
       mavenDeployer {
             repository(url: "repositoryURL") {
                 authentication(userName: "username", password: "password")
             }   
             pom.groupId = 'groupId'    
             pom.version = "1.0.0"  
       }
    }
}

Am I missing something?

Will W
  • 33
  • 4

1 Answers1

1

There is a couple solutions elsewhere on SO:

Publishing a spring boot executable jar artifact:

artifact(file("$buildDir/$project.name-$project.version-${bootRepackage.classifier}.jar")) {
    classifier 'exec'
}

Gradle maven-publish does not build standalone spring-boot application:

publish {
    dependsOn assemble
} 
Community
  • 1
  • 1
alexbt
  • 16,415
  • 6
  • 78
  • 87
  • Thank you! I found that I was using uploadArchives when I could be using the publishing task. With this change, I used your first solution and it did exactly what I wanted. – Will W Sep 14 '16 at 15:31
  • Didn't work for me: Could not find method artifact() for arguments [/var/workspace/build/my-project-unspecified-null.jar, build_b8ejm5oe5e1nrnc8xnmcspqxz$_run_closure3@4227f732] on root project 'my-project' of type org.gradle.api.Project. – Henning Oct 28 '17 at 14:16