How to import additional packages by default in Kotlin

I have my.framework.MyClass which I want to use everywhere in my project as MyClass without any importing. Can I instruct Kotlin compiler to import my.framework package by default as it’s done with classes from its own standard library?

This is currently not possible: https://kotlinlang.org/docs/reference/packages.html#default-imports

Feel free to file a feature request at http://kotl.in/issue.

Was that feature request created I tried to find it, but nothing.
It would be beneficial in many cases to have something like global import.

This feature is implemented in scripting and available in notebook for example. It is also possible to use in your custom scripts, but not in regular code.

1 Like