okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Unknown enum constant DeprecationLevel

Open c-eg opened this issue 2 years ago • 8 comments

After adding OkHttp3 (4.12.0), with Gradle (8.3) and JDK (17.0.7 Corretto), I get the following warnings appear when running gradle build:

...
> Task :compileJava
warning: unknown enum constant DeprecationLevel.ERROR
  reason: class file for kotlin.DeprecationLevel not found
...

c-eg avatar Jan 14 '24 22:01 c-eg

Same as https://github.com/gradle/kotlin-dsl-samples/issues/1301 and https://github.com/square/okio/issues/562

I can check we have this as API

yschimke avatar Jan 14 '24 22:01 yschimke

It looks like we maybe didn't declare an api dependency in 4.x

https://github.com/square/okhttp/blob/parent-4.12.0/okhttp/build.gradle#L24-L25

while we do for

https://github.com/square/okhttp/blob/parent-5.0.0-alpha.12/okhttp/build.gradle.kts#L91-L94

yschimke avatar Jan 19 '24 22:01 yschimke

Any update on this? Is there a way to suppress it? pretty annoying

palexdev avatar Feb 26 '24 23:02 palexdev

I have just tried again with version 5.0.0-alpha.12, and the warning messages still appear.

It's worth noting that adding requires kotlin.stdlib to your module-info.java will stop the warnings from showing.

c-eg avatar Apr 03 '24 17:04 c-eg

@c-eg I think we are using Automatic-Module-Name here https://github.com/square/okhttp/blob/master/okhttp/build.gradle.kts#L54

We don't have a module-info. Should we add an import there?

yschimke avatar Apr 06 '24 11:04 yschimke

I'm not familiar with OSGi, but after a quick look through some documentation, it seems like that might be the necessary fix.

Another thing, the Kotlin documentation for OSGi states

It is recommended to remove kotlin-runtime, kotlin-stdlib and kotlin-reflect dependencies as kotlin-osgi-bundle already contains all of them.

which okhttp3 does not do, maybe this could be addressed at the same time? https://github.com/square/okhttp/blob/dba8478dff0d2492d9d7bfe9c9471b6b3cdb6002/gradle/libs.versions.toml#L68

c-eg avatar Apr 06 '24 18:04 c-eg

This is above my head. Feel free to submit a PR.

@swankjesse might know the fix.

yschimke avatar Apr 06 '24 18:04 yschimke

I forked and built locally, adding the import statement, and then published to maven local; but it didn't fix the issue.

c-eg avatar Apr 06 '24 22:04 c-eg