Amper - Plugin

Amper offers the option to write custom tasks and expose them to your modules via plugins.

On this page

Introduction

Amper philosophy is to give a “batteries included” experience to their users, and this is why they want Amper to cover the most common use cases out of the box. However, a lot of projects have special needs, and the built-in behavior falls short eventually. To address this, Amper offers the option to write custom tasks and expose them to your modules via plugins.

You can create modules with the jvm/amper-plugin product type. These modules contain the Kotlin code implementing your custom tasks, and a plugin.yaml file to register your tasks and their inputs and outputs.

Why do you need to use both Kotlin and YAML? As usual with Amper, tooling is paramount. Thanks to this approach, you will get nice diagnostics in case you make mistakes with your task wiring. Don’t worry, though, navigating between YAML and Kotlin is already seamless with the current basic IDE support.

Task dependencies are automatically inferred based on inputs and outputs, and task avoidance is already available by default. Inputs can be simple scalar values or files, or even your module’s compile or runtime classpath – thanks to the built-in Classpath type. Outputs can be regular files, but they can also be registered as generated sources or resources, so the rest of the build takes them into account.

Build your own plugin from scratch by following the plugin quick-start guide.