I am using the layered jar file approach to reduce the amount of data included in the context sent to the docker daemon. The Docker buildkit [1] functionality adds some intelligence around which files are sent to the Docker daemon. Unfortunately, rather than examining file checksums it appears to be looking at file timestamps. Extracting of the jar file layers using the following command does not preserve file timestamps therefore the entire set of dependency jar files is sent to the daemon each time a build is performed.

java -Djarmode=layertools -jar my-uber-jar.jar extract

I asked this question over on SO and was referred here [2].

Running that command and then checking the timestamps produces this:

$ java -Djarmode=layertools -jar my-uber-jar.jar  extract 
$ ls -l dependencies/BOOT-INF/lib/commons-*
-rw-r--r--  1 legacy  staff   327K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-codec-1.11.jar
-rw-r--r--  1 legacy  staff   204K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-io-2.5.jar
-rw-r--r--  1 legacy  staff   490K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-lang3-3.8.1.jar
-rw-r--r--  1 legacy  staff    60K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-logging-1.2.jar
-rw-r--r--  1 legacy  staff   2.1M Oct  1 09:23 dependencies/BOOT-INF/lib/commons-math3-3.6.1.jar

...and then running it again ~5 minutes later it produces a fresh set of timestamps:

$ java -Djarmode=layertools -jar my-uber-jar.jar extract 
$ ls -l dependencies/BOOT-INF/lib/commons-*
-rw-r--r--  1 legacy  staff   327K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-codec-1.11.jar
-rw-r--r--  1 legacy  staff   204K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-io-2.5.jar
-rw-r--r--  1 legacy  staff   490K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-lang3-3.8.1.jar
-rw-r--r--  1 legacy  staff    60K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-logging-1.2.jar
-rw-r--r--  1 legacy  staff   2.1M Oct  1 09:29 dependencies/BOOT-INF/lib/commons-math3-3.6.1.jar

[1] https://docs.docker.com/develop/develop-images/build_enhancements/ [2] https://stackoverflow.com/questions/69406916/java-layertools-extract-does-not-preserve-timestamps