A simple Github template that lets you create an Android/Kotlin project and be up and running in a few seconds.
This template is focused on delivering a project with static analysis and continuous integration already in place.
Just click on button to create a new repo starting from this template.
Once created don't forget to update the:
buildSrc
.detekt
and ktlint
.For help with issues which you might encounter when using this template, please refer to TROUBLESHOOTING.md
This template is using Gradle Kotlin DSL as well as the Plugin DSL to setup the build.
Dependencies are centralized inside the Gradle Version Catalog in the libs.versions.toml file in the gradle
folder.
This template is using detekt to analyze the source code, with the configuration that is stored in the detekt.yml file (the file has been generated with the detektGenerateConfig
task). It also uses the detekt-formatting plugin which includes the ktlint rules (see https://detekt.dev/docs/rules/formatting/).
This template is using GitHub Actions as CI. You don't need to setup any external service and you should have a running CI once you start using this template, just make sure that you turn on the "Read and Write permissions" on the Action Settings of your repository.
There are currently the following workflows available:
build
, check
and publishToMavenLocal
tasks.-SNAPSHOT
of the libraries to Sonatype.The template is setup to be ready to publish a library/artifact on a Maven Repository.
For every module you want to publish you simply have to add the publish
plugin:
plugins {
publish
}
In order to use this template to publish on Maven Central, you need to configure some secrets on your repository:
Secret name | Value |
---|---|
ORG_GRADLE_PROJECT_NEXUS_USERNAME |
The username you use to access Sonatype's services (such as Nexus and Jira) |
ORG_GRADLE_PROJECT_NEXUS_PASSWORD |
The password you use to access Sonatype's services (such as Nexus and Jira) |
ORG_GRADLE_PROJECT_SIGNING_KEY |
The GPG Private key to sign your artifacts. You can obtain it with gpg --armor --export-secret-keys <your@email.here> or you can create one key online on pgpkeygen.com. The key starts with a -----BEGIN PGP PRIVATE KEY BLOCK----- . |
ORG_GRADLE_PROJECT_SIGNING_PWD |
The passphrase to unlock your private key (you picked it when creating the key). |
The template already attaches -sources.jar
to your publications via the new AGP publishing DSL.
Once set up, the following workflows will take care of publishing:
-SNAPSHOT
versions to Sonatype. The workflow is setup to run either manually (with workflow_dispatch
) or on every merge.If you're using JitPack, you don't need any further configuration and you can just configure the repo on JitPack.
You probably want to disable the [Publish Snapshot] and Publish Release workflows (delete the files), as Jitpack will take care of that for you.
The project includes three sub-projects, each in their own subdirectories:
app
: The source for the final Android application.library-android
: The source for an Android library including UI.library-kotlin
: The source for a UI-less Kotlin library.library-compose
: The source for a UI library with Jetpack Compose library.The following additional top-level directories configure & support building the app & projects:
buildSrc
: Contains shared Gradle logic as precompiled script pluginsconfig
: Contains the Detekt configuration file.gradle
: Contains Gradle Configuration files such as the Gradle Version Catalog and the Gradle Wrapper.Finally, the following hidden top-level directories provide functionality for specific development systems:
.github
: Defines the Github Actions CI tasks and templates for new pull requests, issues, etc..idea
: Sets common initial project settings when the project is opened in Android Studio or IntelliJ IDEA.Feel free to open a issue or submit a pull request for any bugs/improvements.