launchdarkly/java-server-sdk

5.x: Symbols don't resolve in Intellij in a Kotlin project

benasher44 opened this issue · 5 comments

Is this a support request?
I contacted support and in the course of doing that, I tracked down the issue and found a fix. I figured it'd be best to continue here with the technical detail.

Describe the bug
Kotlin projects importing this SDK no longer resolve symbols in IntelliJ, as of version 5 of this SDK. Gradle will still build the project though.

To reproduce

  1. Setup a Kotlin application project
  2. Add this project (@ v5.x) as a dependency
  3. Attempt to use LDUser or LDClient in IntelliJ

Expected behavior
IntelliJ auto-completes and shows you symbols and then auto-imports when you select one. Instead, IntelliJ red-highlights all of your symbols and imports, despite it building properly. This all worked fine in v4.

Logs
Couldn't find helpful logs here sorry.

SDK version
5.0.2

Language version, developer tools

  1. Kotlin 1.3.72
  2. gradle 6.5.1 & 6.6

OS/platform
macOS 10.15.6

Additional context
I got a hint in the public Kotlin slack that it's related to this issue: https://youtrack.jetbrains.com/issue/KT-25709. I tried applying the suggested fix, deploying to maven local, and importing the locally-patched version. The fix worked. Here is the fix. In the shadowJar configuration in build.gradle, add this:

exclude '**/*.kotlin_metadata'
exclude '**/*.kotlin_module'
exclude '**/*.kotlin_builtins'

I'm guessing this started happening due to upgrading this library's dependencies to ones that use the Kotlin stdlib, and maybe before, those dependencies didn't do that.

I'm guessing this started happening due to upgrading this library's to dependencies to ones that use the Kotlin stdlib, and maybe before, those dependencies didn't do that.

I think your guess is right. The SDK now uses OkHttp 4.x, which uses Kotlin; previously it didn't have any Kotlin-based dependencies.

We should have a patch ready before long. Sorry for the inconvenience and thanks for catching this.

No prob thanks!

We've released version 5.0.3. Please let me know if that fixes the issue for you.

Confirmed fixed! Thanks for the quick turnaround!