Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

containerizingMode = 'packaged' does not work with Spring Boot in Gradle

See original GitHub issue

Hi there!

We build our SpringBoot application with a BootJar task (which inherits from Jar) in Graddle, and the new containerizingMode = 'packaged' feature hard-codes the task name to jar:

Would it possible to have this name configurable?


jib {
	jarTaskName = 'bootJar'

(or pass the task object directly, or even explicitly the path to the jar file)

I have currently worked around that by pointing the attributes of jar to bootjar:

jar {
    enabled = false
    destinationDir = tasks.bootJar.getDestinationDir()
    archiveName = tasks.bootJar.getArchiveName()

I guess another alternative could be (not tested and I’d like not to have to rename my bootJar task):

task jar(type: BootJar) {

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

TadCordlecommented, Jan 29, 2020

@maxbrunet We’ve released 2.0.0, which contains this fix!

chanseokohcommented, Nov 25, 2019

@maxbrunet so the best workaround for you should be to enable the jar task to generate a normal (non-fat) JAR. The Spring Boot reference says

By default, when the bootJar or bootWar tasks are configured, the jar or war tasks are disabled. A project can be configured to build both an executable archive and a normal archive at the same time by enabling the jar or war task.

so enabling the jar task is clearly supported by Spring Boot.

jar {
  enabled  = true

But then jar and bootJar will write their respective JAR to the same location, so you’ll need to give a classifier to either one. For example,

jar {
  enabled = true
  classifier = 'original'


jar {
  enabled = true
bootJar {
  classifier = 'boot'

Then Jib will make use of the normal JAR instead of the fat JAR. This will let you avoid duplicating dependencies packaged in the fat JAR. Also this does not require you to manually override the entrypoint to something like java -jar.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build Spring Boot fat JAR using JIB - Stack Overflow
Yes, it is possible to put a fat jar on to the container image using Jib. Please use "containerizingMode" configuration option of Jib:...
Read more >
google/jib - Gitter
I need to use <containerizingMode>packaged mode. But to generate the jar file I use proguard packager (not the normal maven jar packager), do...
Read more >
Spring Boot Gradle Plugin Reference Guide
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring ......
Read more >
Using Jib to containerize Java apps | Google Cloud Blog
For example, Jib's packaged containerizing-mode now works out of the box ... iteration of Maven and Gradle Jib extensions for Spring Boot, ...
Read more >
Jib 2.0.0 has been released - Google Groups
containerizingMode ='packaged'/<containerizingMode>packaged works as intended with Spring Boot projects that generate a fat JAR.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found