proposals/archives/reproducible_jars.md
Relevant issue: #1945
Relevent PR: #2070
| ❌ Aborted ❌ |
|---|
| This proposal is archived but unimplemented, in favor of documentation in the multimodule example: https://github.com/GoogleContainerTools/jib/tree/master/examples/multi-module |
Currently in multimodule builds, jib takes the jars produced by submodule (and subproject) directly from the build system. This means if the build system (gradle, maven) doesn't produce reproducible jars, and jib includes them in the final container, the reproducibility guarantees of jib are not satisfied.
What we want to do is to rewrite these jars to remove any information that could make builds not reproducible.
In order to achieve reproducibility for jars, we need to:
Signed archives will/should not be touched by this process. While we expect that submodule dependencies will not be signed, there's no way for us to know what all users are doing eveywhere. A warning should be presented to the user that signed archives are processed by jib to be reproducible.
Currently the user must configure their build to be reproducible. (we will borrow from these two solutions in our own solution with proper attribution)
In gradle that means configuring the jar task explicitly: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html
jar {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
and removing any changeable meta data from the MANIFEST.MF that they may have previously configured.
In maven, a user must configure an external plugin to do this, one could use: https://github.com/zlika/reproducible-build-maven-plugin on all submodules and potentially achieve this on their own.
Jib should just handle this itself on the PROJECT_DEPENDENCIES layer. For all jars included in the layer, Jib needs to:
MANIFEST.MF and remove values that could change.Jib will not do this for any other layer
Jib can make this configurable, but it should be true by default. A system property like
-Djib.projectDependencies.reproducible=true/false
PROJECT_DEPENDENCIES layerLayerConfiguration -- potentially more performant