gradle-docker-plugin: Shading for Docker Java causes an issue with no being able to resolve JNA classes
I created a plugin to build Docker images based on your plugin. I call DockerBuildImage, but after the update to version 9.1.0 I get an exception:
Exception in thread "docker-java-stream--358492054" java.lang.UnsatisfiedLinkError: 'java.lang.String com.bmuschko.gradle.docker.shaded.com.sun.jna.Native.getNativeVersion()'
at com.bmuschko.gradle.docker.shaded.com.sun.jna.Native.getNativeVersion(Native Method)
at com.bmuschko.gradle.docker.shaded.com.sun.jna.Native.<clinit>(Native.java:223)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.transport.DomainSocket.<clinit>(DomainSocket.java:54)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
at com.bmuschko.gradle.docker.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:9)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
at com.bmuschko.gradle.docker.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
at java.base/java.lang.Thread.run(Thread.java:829)
It is working with version 9.0.1. I use Docker Desktop on MacOS.
The task
Expected Behavior
DockerBuildImage should run like before.
Current Behavior
The task DockerBuildImage was working in version 9.0.1, but after the update to 9.1.0 with the same configuration it does not work. Please see the exception above.
Context
Gradle 7.6
Steps to Reproduce (for bugs)
See project https://github.com/m-raab/docker_gradle_testproject
and run gradlew :buildMyAppImage
Your Environment
I use Docker Desktop on MacOS - Docker Desktop 4.15.0 (93002) JDK 11 is used.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 33 (20 by maintainers)
Commits related to this issue
- Downgrade docker-remote-api from 9.1.0 to 9.0.1 Due to: https://github.com/bmuschko/gradle-docker-plugin/issues/1147 — committed to creek-service/creek-system-test by big-andy-coates a year ago
- Downgrade docker-remote-api from 9.1.0 to 9.0.1 (#198) Due to: https://github.com/bmuschko/gradle-docker-plugin/issues/1147 — committed to creek-service/creek-system-test by big-andy-coates a year ago
- Downgrade docker-remote-api from 9.1.0 to 9.0.1 Due to: https://github.com/bmuschko/gradle-docker-plugin/issues/1147 — committed to creek-service/creek-kafka by big-andy-coates a year ago
- Downgrade docker-remote-api from 9.1.0 to 9.0.1 (#208) Due to: https://github.com/bmuschko/gradle-docker-plugin/issues/1147 — committed to creek-service/creek-kafka by big-andy-coates a year ago
- Revert bmuschko plugin update Even on Windows we experience the following issue: https://github.com/bmuschko/gradle-docker-plugin/issues/1147 We should retry 9.2.0 when its released. — committed to SSI-Solutions/vcms by hosszub-adn a year ago
@big-andy-coates I believe that can be worked around by declaring the artifact
Looks like we should exclude the JNA library from relocating/shading. I’d like to do two things here: