A universal Kotlin library template designed to kickstart your Kotlin library projects with ease. This template provides a robust and scalable foundation for library development, with built-in automation tools to guide you from initial setup to publishing your library effortlessly.
- Quick Start: No complex setup required. Simply fork this template, adjust the settings, and start coding.
- Modular Structure: Designed from the ground up to support splitting your library into multiple smaller libraries, enabling more granular access and flexibility for users of your project.
- Powered by Kotlin Multiplatform: Offers full flexibility in choosing your target platforms
- Automated Publishing: Fully configured Gradle setup for publishing to Maven Central or other package repositories.
- Best Practices Included:
- Explicit API mode to enforce visibility to be specifically declared.
- Automatic versioning following Semantic Versioning principles.
- Gradle version catalog for easy and clean cross module dependency management.
- Gradle convention plugins for consistent and reusable project configuration.
- Automatic dependency version checks and updates via Gradle Versions Plugin.
- static code analysis with detekt and ktlint.
- OSS Review Toolkit integration for automated license compliance checks.
- Testing setup and coverage reporting out of the box.
- CI/CD Ready: Preconfigured GitHub Actions workflows for seamless builds and releases.
This template comes with a powerful automated publishing system:
-
Secure Configuration:
- Handles sensitive data such as access tokens securely through environment variables.
- Built-in support for CI/CD workflows ensures safe and consistent deployments.
-
Automatic Versioning:
- Semantic Versioning is automatically managed based on tags or commit messages.
- No manual updates required in your
build.gradle.kts
.
-
Use the Template:
- Fork the repository or use it directly as a GitHub Template.
- Customize
settings.gradle.kts
andbuild.gradle.kts
to suit your project.
-
Adjust Modules:
- Modify the
core
andexample
modules, or add new ones to expand functionality.
- Modify the
-
Automated Releases:
- Use GitHub Actions for automated CI/CD workflows.
- The GitHub action requires the following secrets to be set in your project settings to be able to publish to Maven Central:
MAVEN_CENTRAL_USERNAME
MAVEN_CENTRAL_PASSWORD
SIGNING_IN_MEMORY_KEY
SIGNING_IN_MEMORY_KEY_ID
SIGNING_IN_MEMORY_KEY_PASSWORD
- You can find more information about how to get the required maven central credentials here or here or in the official documentation.
- The GitHub action requires the following secrets to be set in your project settings to be able to publish to Maven Central:
- Publishing To Maven Local:
-
./gradlew publishToMavenLocal
-
- Use GitHub Actions for automated CI/CD workflows.
This template includes ready-to-use GitHub Actions workflows for:
- Build & Test: Ensures your library is reliable and bug-free.
- Release: Automatically publishes new versions when a release tag is created.
- Linting: Keeps your code clean and adherent to Kotlin standards.
Please change the <key id>
placeholder in the following command to your signing key id.
gpg --export-secret-keys --armor <key id> | grep -v '\-\-' | grep -v '^=.' | tr -d '\n'
This repository is licensed under the MIT License.
With this template, you can focus on writing great code while the boilerplate tasks are taken care of. Happy coding! 🎉