What is a Kotlin module?

后端 未结 2 1597
一生所求
一生所求 2021-01-17 09:18

In the Kotlin documentation they are mentioning some kind of module for instance in the documentation for the internal modifier.

However I coul

相关标签:
2条回答
  • 2021-01-17 09:55

    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. :)

    0 讨论(0)
  • 2021-01-17 10:10

    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.

    0 讨论(0)
提交回复
热议问题