sKnak
sKnak

Reputation: 81

gradle: Task :jar SKIPPED while I get my jar with gradlew build

My Question is: Why does the jar-creation work with gradlew build, while I see "Task :jar SKIPPED" when I click on jar in intellij's gradle window ? And how can I fix it in IntelliJ ?

( yesterday I failed in maven with "no main manifest attribute in .... .jar )

Upvotes: 8

Views: 9989

Answers (2)

Soufiane D
Soufiane D

Reputation: 111

You can enble this, with add code below in projectName.gradle it works for me :

  • spring-boot : 2.0.8.RELEASE

  • Gradle : 4.5 or >

    jar { baseName = 'projectName' enabled=true

manifest { .... } }

Upvotes: 0

M.Ricciuti
M.Ricciuti

Reputation: 12116

This is because Springboot Gradle plugin will create a bootJar task and by default will disable jar and war tasks, as described here: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#packaging-executable-and-normal

So you need to execute bootJar task , from the IDE. When executing gradlew build, the tasks bootJar gets automatically executed, due to tasks dependencies created by the plugin.

When running task build (from console or IDE), you can see the tasks executed by Gradle depending on tasks dependencies, e.g.:

> Task :backend:compileJava
> Task :backend:processResources
> Task :backend:classes
> Task :backend:bootJar      ## <== this is the task register by Springboot plugin, which produces the "Fat/executable" jar
> Task :backend:jar SKIPPED  ## <== task disabled by Springboot plugin
> Task :backend:assemble
> Task :backend:processTestResources
> Task :backend:testClasses
> Task :backend:test
> Task :backend:check
> Task :backend:build

For your remark

the jar runs fine, it finds the main class - even without jar manifest attribute in build.gradle

The Springboot plugin will automatically configure this for you, see : https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#packaging-executable-configuring-main-class

EDIT 27-05-2021 Starting from Springboot 2.5, the jaris not disabled by default anymore. see more details in release notes here

Upvotes: 17

Related Questions