question-mark
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.

Feature request: Support configuration or new task that doesn't package a Java app, just specified paths.

See original GitHub issue

Jib and the associated Gradle plugin look to solve a number of problems i’ve come across, and whilst the jib-cli is a great escape hatch to supporting any kind of app/packaging needs the gradle plugin specifically is a great help ergonomically, it avoids having to create jib files and makes it easy to programmatically change jib config per module/project. So I want to use jib and jib gradle plugin, but not all of my containers are Java and even those that are Java I don’t really want to package the app the way Jib wants to out of the box (exploded or packaged modes).

A good way to solve both of these issues would be to tweak the jib gradle plugin to not always assume that a Java app is being packaged, make it an optional addition (defaulted to on for backwards compat) with the disabled state just packaging all the files specified in the extraDirectories section. This way I can use Jib and the gradle plugin, avoid jib files and keep simple per module config AND use the same system for both Java apps and nginx and stubs… etc all of the variety of apps. A slightly different more gradle-aware approach would be to support Gradle Distributions/Applications, whereby Jib aims to package a Gradle application (essentially just a zip/tar constructed by Gradle - https://docs.gradle.org/current/userguide/application_plugin.html) and what is in that application is controlled by Gradle thus breaking the Java app assumption/dependency.

My current workaround is to apply `java-library’ plugin to all my gradle projects so Jib does all the packaging of essentially nothing, just to avoid it failing because the ‘jar’ task doesn’t exist! Quite the silly workaround =)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nhoughtocommented, Nov 8, 2021

yep makes sense, ok so coordinating concurrent jib builds to share layers will need to be done outside of jib/in gradle itself. My scenario is building 20~ gradle application distributions, they are all java services that share most 3rd party dependencies, this should be easy to split out into its own layer that could be shared. Seems like i’ve got all I need to make that happen, thanks.

0reactions
chanseokohcommented, Nov 8, 2021

Jib caches base image layers and application layers.

The base image layer cache is shared by all Jib tools (Maven and Gradle plugins and Jib CLI). So, as long as base image layers are cached once, they will be reused by any number of concurrent threads or processes running Jib tools.

OTOH, the application layer cache is by default local to each project (build/jib-cache for Gradle and target/jib-cache for Maven). Usually there’s no value to share application layers between projects, since each project is unique and it’s rare that two or more projects build the exact same layers. However, if you have multiple projects that at least have some layers that are built identically, I think it’s not a bad idea to share them by setting their application cache directory to a global location. Check out the jib.applicationCache system property.

Lastly, I think you already know this, but just in case: in order for two layers (which are simply .tar files) to be identical, they should be equal byte-to-byte, resulting in the same digest checksum. Even having a different timestamp for a file makes it different. Good news is that, Jib wipes out highly volatile and system-dependent information like file timestamps, permissions, etc., so it results in strong reproducibility and cacheability, saving storage, network bandwidth, and time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Packaging and Distributing Java Desktop Applications
We will package the application in the form of an executable JAR file. ... If the script does not work for you, see...
Read more >
Build your Java image - Docker Documentation
The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in...
Read more >
Toolchains for JVM projects - Gradle User Manual
Setup all compile, test and javadoc tasks to use the defined toolchain which may be different than the one Gradle itself uses. Gradle...
Read more >
Configure your build - Android Developers
Each build configuration can define its own set of code and resources while reusing the parts common to all versions of your app....
Read more >
9 Installation of the JDK and the JRE on Microsoft Windows ...
For JDK 9, you are given the option of installing the following features: Development Tools. Source Code. Public Java Runtime Environment.
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found