"no main manifest attribute" when trying to execute fat jar

gradle, maven, spring-boot

Solution

After looking through the debug log of gradle uploadArchives and gradle build, I found that bootRepackage was not called after regenerating the jar when uploading archives.

This is related to this issue in the spring-boot gradle plugin, and bootRepackage not integrating properly with the jar task:

https://github.com/spring-projects/spring-boot/issues/1113

I just had to add the following in my gradle script:

uploadArchives.dependsOn bootRepackage

Problem

I have a simple spring-boot microservice project, and I am trying to get it to deploy to my maven repository. When I create my jar file through ``` gradlew build ``` I can execute my fat jar with ``` java -jar build/libs/tws-0.1.1-SNAPSHOT.jar ``` However, when I upload the jar to artifactory, through uploadArchives, this is the contents of my MANIFEST.MF: ``` Manifest-Version: 1.0 ``` Obvioulsy something wrong here, and when I download the artifact and try to execute it, I get the error "no main manifest attribute". When I look at the debug log of uploadArchives, I can see that the jar is rebuilt, and it might be that the spring boot plugin for gradle is somehow shorted in this process.

Original source