kubernetes-client / java

Official Java client library for kubernetes
http://kubernetes.io/
Apache License 2.0
3.57k stars 1.9k forks source link

Library cannot be used due to split package exported by dependencies #3769

Open cowwoc opened 2 hours ago

cowwoc commented 2 hours ago

Describe the bug This library is incompatible with Java Modules. If you run mvn dependency:tree you will see:

[INFO]    +- io.kubernetes:client-java-api:jar:21.0.1:compile
[INFO]    |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO]    |  +- jakarta.annotation:jakarta.annotation-api:jar:3.0.0:compile
[INFO]    |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
  1. The library depends on both javax.annotation and jakarta.annotation. I believe the latter is meant to replace the former.
  2. Both javax.annotation and jsr305 export the same package.

Anyone who tries declaring this library as a dependency will get this error:

module X reads package javax.annotation from both jsr305 and java.annotation

Client Version 21.0.1

Java Version 23

To Reproduce Create an application that contains a module-info.java that contains the following lines:

requires io.kubernetes.client.java;
requires io.kubernetes.client.java.api;

Expected behavior Ability to use from Java Modules. You'll need to replace all uses of javax.annotation by jakarta.annotation and ideally please find a replacement for JSR 305. See https://nipafx.dev/jsr-305-java-9/ for what a mess it is on Java 9+.

cowwoc commented 2 hours ago

This issue is related to https://github.com/kubernetes-client/java/issues/2606