Search code examples
gradlespring-bootlauncher

How to specify the Launcher in Spring Boot Gradle?


There three launcher in Spring Boot: JarLauncher/PropertiesLauncher/WarLauncher. For executable jar, JarLauncher will be used by default. Now I want to use PropertiesLauncher instead so that I could use external classpath. How could I specify that is spring boot gradle plugin?

Accoring to D3.1 of this doc D.3.1 Launcher manifest, I can specify the main class in MANIFEST.MF like this:

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.mycompany.project.MyApplication

However, in Spring Boot Gradle, the following code snippet actually specifies the Start-Class, not the Main-Class:

springBoot {
    mainClass = "com.sybercare.HealthServiceApplication"
}

Do I need to create the MANIFIEST.MF manually or there is a better way to do this?

Thanks!


Solution

  • Add the layout property:

    springBoot{
        mainClass = "com.sybercare.HealthServiceApplication"
        layout = "ZIP"
    }
    

    layout = ZIP Triggers SpringBoot to use the PropertiesLauncher