TODO
Modularitzar
An Amper project is defined by a project.yaml file. This file contains the list of modules and the project-wide configuration. The folder with the project.yaml file is the project root. Modules can only be located under the project root (at any depth). If there is only one module in the project, the project.yaml file is not required.
Each module describes a single product. Several modules can’t share the same sources or resources, but they can depend on each other. How to produce the desired product, that is, the build rules, is the responsibility of the Amper build engine.
Make the project multiplatform
|-app/
| |-src/
| | |-main.kt
| |-...
| |-module.yaml
|-lib/
| |-src/
| | |-util.kt
| |-module.yaml
|-project.yamlEn el cas anterior, el project.yaml es veu així:
modules:
- app
- libConsulta la referència per a més opcions per definir la llista de mòduls al fitxer project.yaml.
Dividim el nostre projecte en una aplicació JVM i un mòdul de biblioteca, amb codi compartit que reutilitzarem més tard quan fem el projecte multiplataforma.
El nostre objectiu aquí és separar la nostra aplicació en un mòdul de biblioteca shared i un mòdul d’aplicació jvm-app i aconseguir la següent estructura:
Recursos
In multiplatform modules resources are merged from the common folders and corresponding platform-specific folders:
|-src/
| |-...
|-resources/ # these resources are copied into the Android and JVM artifact
| |-...
|-resources@android/ # these resources are copied into the Android artifact
| |-...
|-resources@jvm/ # these resources are copied into the JVM artifact
| |-...In the case of duplicating names, the common resources are overwritten by the more specific ones. That is resources/foo.txt will be overwritten by resources@android/foo.txt.
Android modules also have res and assets folders:
|-src/
| |-...
|-res/
| |-drawable/
| | |-...
| |-layout/
| | |-...
| |-...
|-assets/
| |-...
|-module.yamlEstá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