Module
An Amper module is a directory with a module.yaml configuration file, and optionally sources and resources.
Introduction
Amper …
An Amper module is a directory with a module.yaml configuration file, and optionally sources and resources. A module configuration file describes what to produce: e.g. a reusable library or a platform-specific application.
Module layout
Here are typical module structures at a glance:
my-module/
├─ resources/
│ ╰─ logback.xml
├─ src/
│ ├─ main.kt
│ ╰─ Util.java
├─ test/
│ ╰─ MainTest.java
│ ╰─ UtilTest.kt
├─ testResources/
│ ╰─ logback-test.xml
╰─ module.yamlAll sources and resources are optional: only the module.yaml file is required. For example, your module could get all its code from dependencies and have no src folder.
TODO: https://amper.org/latest/user-guide/basics/#module-file-anatomy
Working environment
Open the Idea editor and install the Amper plugin.
Create a “JVM console application” project:

Module
An Amper module is a directory with a module.yaml configuration file, source files, and resources that describes a single product.
A module configuration file describes what to produce: for example, a reusable library or a specific application for desktop, Android, or other platforms.
Since you’ve created a simple JVM project, the content of the module.yaml file is minimal.

The file is in YAML format (check the activity if you don’t know what it is).
A module consists by default of the src and test folders.

The main.kt and WorldTest.kt files are normal Kotlin files with nothing special.
To run an application, use the ‘run’ icon (product section of the module.yaml file:

You can also use the ‘run’ icon ( main() function:

Source code
Source files are located in the src folder:
|-src/
| |-main.kt
|-module.yamlBy default, the entry point for JVM applications (the main function) is expected to be in a main.kt file (case-insensitive) in the src folder.
This can be overridden by specifying an explicit main class in the module configuration:
product: jvm/app
settings:
jvm:
mainClass: dev.xtec.TotoKtIn Kotlin, the main function is usually found at the top level of the file.
However, the JVM expects a main class when running any application.
Kotlin always compiles top-level declarations
into a class, and the name of this class is derived from the filename by capitalizing the name
and converting the .kt extension into a Kt suffix.
For example, top-level declarations from toto.kt will be in a class named TotoKt.
Estás leyendo una vista previa.
Inicia sesión para leer el artículo completo. Cualquier cuenta abre 4 artículos gratuitos al mes; el alumnado y el profesorado leen las páginas de su curso sin límite.
Iniciar sesión