Home > Blockchain >  IntelliJ IDEA - Kotlin Maven Dependency Not Loaded in Kotlin Project
IntelliJ IDEA - Kotlin Maven Dependency Not Loaded in Kotlin Project

Time:10-15

I am experiencing some strange behavior when working with maven 3, the latest version of IntelliJ IDEA, java 8 and kotlin 1.5:

  • I have a Kotlin jar to use as a dependency in my local file system.
  • When creating a new Java project, adding maven framework and adding the dependency (with system scope) to my POM, it loads correctly into my IntelliJ classpath and I can use it in my code.
  • When creating a Kotlin project, adding maven framework and adding the dependency with an identical POM to the java project, IntelliJ does not load the dependency. Strangely, it appears under "external libraries", I just can't resolve any imports to dependency classes in my project.
  • mvn dependency:tree for both projects prints my kotlin dependency, meaning that maven has found my dependency but IntelliJ hasn't.

This is the POM I am using: https://pastebin.com/bAFkaYDE

How I can get the kotlin IntelliJ IDEA project to notice my maven dependency kotlin jar?

UPDATE: I have tried this same test but with gradle java/kotlin projects, with the exact same results. This is an issue with IntelliJ IDEA not picking up kotlin based dependency jars specifically from both maven and gradle projects.

CodePudding user response:

After much debugging, I have discovered that this is because my library had the kotlin runtime dependencies bundled into it. Because of this, IntelliJ fails to load the dependency from either build system, but does not output about so anywhere. This is why Maven/Gradle are still able to build the project, but IntelliJ can't resolve the dependency.

  • Related