This project contains references to all Ktor plugins available in the web-based Ktor project generator and the IDEA plugin.
To add a new plugin, follow these easy steps:
-
Publish your project to Maven.
- Use the gradle maven publish plugin to publish to Maven Central or some other public Maven repository.
- If you'd like to reference another repository, this can be referenced from the plugin manifest in Step 3.
-
Fork and clone this repository.
-
Run
./gradlew --console=plain -q createPlugin
- This will prompt you with a couple questions about the new plugin.
- After it is completed, you should have some new files in this structure:
plugins └── server └── <group> ├── group.ktor.yaml └── <plugin-id> ├── versions.ktor.yaml └── 2.0 ├── manifest.ktor.yaml ├── install,kt └── documentation.md
- You can include any number of install files for populating new projects. More information under
templates/manifest.ktor.yaml. The existing plugin files under the
plugins folder can also be useful reference for introducing new plugins.
-
Run
./gradlew buildRegistry
to test the new files. -
Run
./gradlew buildTestProject
to generate a sample project.- You can now experiment with a project generated with your plugin.
- Iterate on updating the new files, building the registry, and generating the test project until you're happy with the results.
-
Create a pull request with the new changes.
- Once merged, your plugin will be available in the ktor project generator.
To supplement the reference templates, we have many plugin examples that can be of some aid when adding your own.
Here are a few examples to illustrate different techniques that you can apply for your extensions:
plugin | features |
---|---|
koin | Basic layout with an extra source file |
exposed | Several injections and dependencies |
ktor-server-kafka | Includes configuration files and a custom repository |
kotlinx-rpc | Multi-module layout with core, client, and server |