jib: Jib 3.4.2 build fails
Environment:
- Jib version: 3.4.2
- Build tool: Gradle 8.7
- OS: macos
When I run
./gradlew jibDockerBuild
It fails with
Caused by: java.lang.NoSuchMethodError: 'void org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry)'
at com.google.cloud.tools.jib.tar.TarStreamBuilder.writeAsTarArchiveTo(TarStreamBuilder.java:52)
at com.google.cloud.tools.jib.image.ImageTarball.dockerWriteTo(ImageTarball.java:166)
at com.google.cloud.tools.jib.image.ImageTarball.writeTo(ImageTarball.java:84)
at com.google.cloud.tools.jib.docker.CliDockerClient.load(CliDockerClient.java:195)
Workaround. It works when I set this in both root and gradle submodule build.gradle.kts
buildscript {
dependencies {
classpath("commons-codec:commons-codec:1.16.1")
}
configurations.all {
resolutionStrategy {
force("org.apache.commons:commons-compress:1.26.0")
force("commons-codec:commons-codec:1.16.1")
}
}
}
Please make it work w/o workarounds
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 23 (8 by maintainers)
If your project is a multi-module one, then it’s pretty common that
./gradlew buildEnvironmentlies about how it resolved build environment dependencies; it’s a long-standing Gradle bug where build dependencies declared in the parent project shamelessly and silently overrides dependencies of sub-projects, as opposed to what you see from./gradlew buildEnv.So, if you haven’t done so, I recommend first that you strictly follow these instructions for setting up your multi-module project. That is, declare all your plugins in the project root while not applying them and then selective apply plugins in sub-projects.
UPDATE: another case of Gradle lying with
./gradlew buildEnvwas https://github.com/GoogleContainerTools/jib/issues/4235#issuecomment-2066685245 where an old version of the Apache library was silently pulled in frombuildSrc/build.gradle.Moving the jib plugin version definition to the root of my multi-module project with
apply falseand using it at the subproject solved the issue for me as well.I had some free time to look into why my build fails and in my case
buildEnvironmentwasn’t telling me the truth, because it did not include the dependencies frombuildSrc(I have a custom plugin for jOOQ that spins up a testcontainer, to build the DB and generate the DSL).Revealed this:
While running
./gradlew buildEnvironmentwas telling me that nothing usescommons-compressexceptjiband it is on version1.26.0which wasn’t the case.And in this particular case testcontainers already tracks the update, so it’s just a matter of time until the order is restored again… https://github.com/testcontainers/testcontainers-java/issues/8338
The fix was also simple once I figured out what was the problem, I’ve added the following into my
buildSrc/build.gradlewhere I hadtestcontainersdefined:And now both, testcontainers and jib, seem to be working for me.
@mihalyr-prospect there you go! As you saw, the cause is that Gradle pulls in an old version of some library in your build environment for one reason or another where
./gradlew buildEnvlies, which is a known Gradle issue. All you have to do is to resolve your diamond dependency conflict in your project in one way or another. Glad you were able to fix it.you can take any base spring boot project on 3.2.4
@chanseokoh Aligning the versions in de root project plugins block fixes the problem in our multi-module project. Good to know about this obscure Gradle issue/bug, thanks!
Here is a non multi-module project
buildEnvironment(also spring-boot but not using the spring-boot gradle plugin), our compress comes from Jib and it also broke ourjibBuildTarstep after3.4.2This is on Gradle (wrapper) 8.6, Java 21, and Linux (Fedora 38, but also failing in GitHub CI on ubuntu-latest).
It seems to be the same issue as reported above:
Stacktrace: