What is a Kotlin module?

From the Kotlin's documentation, a module is a set of Kotlin files compiled together:

  • an IntelliJ IDEA module
  • a Maven project;
  • a Gradle source set
  • a set of files compiled with one invocation of the <kotlinc> Ant task.

That is @hotkey's, but I would like to complement this answer.

According to Andrey Breslav, the Lead Language Designer of Kotlin:

a Kotlin module maps one-to-one to IntelliJ's module (iml-file).

According to IntelliJ's documentation:

Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules for a project and each of them can be responsible for its own framework.

When it comes to a Maven project or a command line compilation, Andrey states:

Each compiler run, by default, is a separate module: all the binary dependencies will be treated as being not in the module being compiled at the moment.

Also, a Gradle source set is a module, with the exception that the test source set can access the internal declarations of main.

This means that if you have different build flavors in your Gradle configuration resulting in different source sets, for production and debug versions for example, then an internal class from one source set would not be available to be used in another source set.


A module is a set of Kotlin sources compiled together:

  • an IntelliJ IDEA module;
  • a Maven project;
  • a Gradle source set;
  • a set of files compiled with one invocation of the Ant task.

This is in the same docs article about visibility modifiers. :)

Tags:

Kotlin