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 ?

  • Just created something with spring initializer and loaded the project in intellij as it is. ( it is org.springframework.boot, .. 'org.springframework.boot:spring-boot-starter-web')
  • I wonder about Task :jar SKIPPED ( nor jar created )
  • and than I discovered that I get the jar when I start from console.
  • ( and the jar runs fine, it finds the main class - even without jar manifest attribute in build.gradle)

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

1

2 Answers

This is because Springboot Gradle plugin will create a bootJar task and by default will disable jar and war tasks, as described here:

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 :

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

0

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 { .... } }

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like