Search code examples
gradleintellij-ideakotlinbukkit

IntelliJ IDEA unable to resolve fine working gradle dependency


I'm currently working on a Kotlin project with Gradle (source code here). It's a Bukkit plugin which depends on a library I maintain (library source code here). When running ./gradlew assemble in a terminal, everything works fine and the build succeeds (log below).

$ ./gradlew assemble --console plain

> Task :compileKotlin
w: Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
w: /home/axel/.gradle/caches/modules-2/files-2.1/com.github.axelrindle/PocketKnife/v1.3.0/b2303013bfd8e21c419f1d640ef374afc48e86af/PocketKnife-v1.3.0.jar: Library has Kotlin runtime bundled into it

> Task :compileJava NO-SOURCE
> Task :processResources
> Task :classes
> Task :inspectClassesForKotlinIC
> Task :jar
> Task :assemble

BUILD SUCCESSFUL in 5s
4 actionable tasks: 4 executed

But when working in IDEA, my library is the only one the IDE fails to resolve for whatever reason.

I've already tried the following steps:

  • Delete gradle/idea caches (~/.gradle/caches;.idea)
  • Reinstall IDEA
  • Delete IDEA config directory (.IdeaIC2019.1)
  • Reimport the project in IDEA

I've already read the following questions/answers, but none of them worked:

Also, my idea.log can be found here: https://pastebin.com/0Z5b3Wdp

Last but not least some version information:

IntelliJ IDEA 2019.1.3 (Community Edition)
Build #IC-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.18.0-21-generic
$ ./gradlew --version

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          12.0.1 (Oracle Corporation 12.0.1+12)
OS:           Linux 4.18.0-21-generic amd64


Solution

  • After a lot of failed troubleshooting, I found out what the problem was. My library contained the bundled kotlin runtime, which was causing impossible to debug resolving issues with IDEA. I split up the project into multiple subprojects, where the actual api dependency does not bundle the kotlin runtime. This fixed my issues.