How to create a auto executable Jar in Gradle


(Ondweb) #1

when running jar for each modules it says like “no manifests in main attribute for the $module name”.

When I am specifying the main class in build script this works.

Do we have a plugin to search for main method & Jar should be auto executable.

Thanks in Advance!


(Mark Vieira) #2

If you want to create an executable JAR you need to supply a value for the Main-Class attribute in the manifest.

jar {
  manifest {
    attributes 'Main-Class': 'com.company.Main'
  }
}

(Ondweb) #3

Thanks for your response.
I know this should work.But if we don’t specify main-class in our build script,Do we have any plugin to search for main class & make the Jar executable.
I think in maven we have a spring-boot-maven-plugin will do that & am looking for similar plugin to do here.


(Mark Vieira) #4

This is a spring boot plugin for Gradle as well that has this capability. However, this is limited to Spring Boot projects. No such plugin exists for generic Java applications that I’m aware of. Perhaps an opportunity for contribution :slight_smile: