Can't import Kotlin libraries with Maven

I’m having an interesting problem where I can specify Java dependencies in pom.xml, and they all load in fine. But any Kotlin dependencies appear to load in correctly, but I get no auto-completion and a build error if I try to use anything within said dependency. The error is the standard ‘unresolved reference’ error.

I’ve put a barebones sample project on Github here: https://github.com/danclarke/kotlinimportfail

I’ve checked the docs for anything special re. Maven and Kotlin projects, but couldn’t find anything. Any help would be much appreciated :slight_smile:

1 Like

First, it’s not only an import problem — the project doesn’t compile with mvn test command as well.

I suppose there’s a problem with com.willowtreeapps.assertk:assertk-jvm artifact’s pom file. Since that’s an artifact with .jar file, its pom should have the packaging attribute set to jar rather than pom.

If you change the type of the dependency to jar (or just omit it as the other dependencies do), the project builds fine and IDE recognizes that API from assertk package.

I suggest you to open an issue about this problem with assertk in maven projects in the issue tracker of this library: Issues · willowtreeapps/assertk · GitHub.

That’ll do it! It was happening with another project too, seems the first two projects I tried to import had the exact same problem. I knew it must be something I did.

I’ll open an issue. Thanks for your help!