A module is a unit of compilation in Kotlin. Physically, modules are described by build scripts. Such scripts programmatically assemble module descriptors that carry information about source files that constitute the module, dependencies, and compiler options used to build the module.
Being a unit of compilation means that all the analyses and optimizations may be performed module-wise, and that binary compatibility issues arise only on module boundaries.
Module identifiers and root namespaces
Each module must have a unique identifier. This becomes and identifiers for the module's root namespace – the one all other namespaces in that module reside in.
A build script for a module may specify a set of default imports for its source files. It is convenient to import ubiquitously used libraries (like collections, UI, etc) by default.
Kotlin does not require any particular layout of source files in the file system: a namespace may not correspond to a directory, and a class may not occupy its own file. I.e. one can put all the source code for a module into a single source file.
Modules can depend on other modules, and specify version requirements for their dependencies.
While exact API is not settled yet, the module script file may look like this: