Gradle does not add the correct main-class entry in the manifest.mf file
11:16 05 Dec 2025

I have tried for days now to get the Gradle build to produce a Spring Boot jar file that will run. Everything builds ok except for one thing. Gradle does not put the correct main-class entry in the manifest.mf file. It puts:

Main-Class: org.springframework.boot.loader.JarLauncher
instead of:
Main-Class: org.springframework.boot.loader.PropertiesLauncher

in the manifest file. No matter what I've tried so far that Gradle accepts as a properly formatted build.gradle file, will produce a manifest.mf file with that one entry that I need the PropertiesLauncher class.

I've tried every example I could fine with Google in my build.gradle file. It builds fine but refuses to add the correct main-class entry in the manifest.

If I manually add the main-class entry in the file and splice it back into the jar everything work fine. My program launches just fine and everything is great. This is a multi-project Gradle build.

The following is my gutted build.gradle. There is some possible proprietary stuff in it, and delete hopefully unnecessary stuff. I'm hopping there is enough here for analysis. If more is needed I might have to cough up more info. Hopefully most of what's needed is in the bootJar task.

import java.text.SimpleDateFormat

import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardCopyOption

plugins {
//    id 'org.springframework.boot' version '3.2.0'
    id 'application'
    id 'java'
    alias(libs.plugins.springBootPlugin)
//    alias(libs.plugins.springDependencyManagementPlugin)
//    id 'org.springframework.boot' version '3.2.0' // Apply the Spring Boot plugin
    id 'io.spring.dependency-management' version '1.1.4' // Recommended for managing Spring Boot dependencies
}

application {
    mainClass = 'org.springframework.boot.loader.PropertiesLauncher' 
}
//mainClassName = 'org.springframework.boot.loader.PropertiesLauncher'

java {
  sourceCompatibility = JavaVersion.VERSION_1_8
  targetCompatibility = JavaVersion.VERSION_1_8
}

apply plugin: 'org.springframework.boot'

ext{
  group   = rootProject.properties.get('groupId')
//  version = rootProject.properties.get('cupps.platform.version')
}

configurations {
    wrapperservice
}

ext {
}

dependencies {
            
    // The following JMX stuff does not exist on Maven anymore.
    // So we get them from maven-releases on our Nexus repository
    implementation 'com.sun.jmx:jmxri:1.2.1'
    implementation 'com.sun.jdmk:jmxtools:1.2.1'
    implementation 'javax.management:jmxremote:1.0.1_04'
}

tasks.named("compileJava") {
}

// To disable the standard 'jar' task if you only want the bootJar
jar {
    enabled = false
}

// Configuring the Main Class
// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#packaging-executable.configuring.main-class
tasks.named("bootJar") {

    archiveFileName = "${artifactId}-${project.property('cupps.platform.version')}.jar" 
    println "version2: " + "${artifactId}-${project.property('cupps.platform.version')}.jar" 

    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    //mainClassName = 'com.arinc.afd.cupps.Application'   // For Spring Boot Gradle Plugin version 2.6.x and above
//    mainClassName = 'org.springframework.boot.loader.PropertiesLauncher' // For Spring Boot Gradle Plugin version 2.5.x and below

    exclude ('**/batik*.*')
    exclude ('**/service-wrapper.zip')
    
    // To include the properties files, conf files, and xml file, etc under the resources folder into the JAR file.
    from sourceSets.main.resources

// 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'

    manifest {
        attributes (
                'Start-Class' : 'com.arinc.afd.cupps.Application',
                'Built-By' : "${builtBy}",
                'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
                'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
                'Created-By' : "${createdBy}",
                'Specification-Title' : "${specTitle}",
                'Specification-Vendor' : "${specVendor}",
                'Specification-Version' : "${specVersion}",
                'Implementation-Title' : "${implementTitle}",
                'Implementation-Vendor' : "${implementVendor}",
                'Implementation-Version' : "${implementVersion}",
        )
    }
}

java spring gradle boot