Spring Boot 2.5.0 generates plain.jar file. Can I remove it?

Solution 1:

It was a change in Spring Boot 2.5.0.

As @ThomasKläger pointed out: You can set it in the build.gradle configuration.

build.gradle

jar {
    enabled = false
}

For Kotlin devs:

tasks.getByName<Jar>("jar") {
    enabled = false
}

Alternatively, you can run the bootJar task. It produces only the default runnable jar.

Solution 2:

try use follow setting:

jar {
   enabled = true
   archiveClassifier = '' //use empty string
}

because org.springframework.boot.gradle.plugin.JavaPluginAction.java

        private void classifyJarTask(Project project) {
    project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class)
            .configure((task) -> task.getArchiveClassifier().convention("plain"));
}

from spring-boot-gradle-plugin sources file: https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-gradle-plugin/2.5.0/spring-boot-gradle-plugin-2.5.0-sources.jar

see:
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveClassifier

Solution 3:

This gradle config will produce myprogram-0.0.1.jar instead of myprogram-0.0.1-plain.jar

In your build.gradle.kts

// Build executable jar
tasks.jar {
    enabled = true
    // Remove `plain` postfix from jar file name
    archiveClassifier.set("")
}