Welcome to Librarian
Librarian is an opinionated toolkit to build Kotlin libraries.
Librarian:
- publishes your KMP/Android/JVM libraries to:
- Maven Central releases
- Maven Central snapshots
- Google Cloud Storage
- generates versioned KDoc using Dokka
- automates your workflows using GitHub actions:
- pull requests
- documentation
- SNAPSHOTs
- releases
- generates a Kotlin property holding your library version
- monitors your binary compatibility using Kotlin Binary Compatibility validator
- configures Java and Kotlin compatibility
- ensure your libs can be consumed with maven
- and more!
Get started
1/4 Add it to your project
Add the Gradle plugin to your root build.gradle.kts
:
plugins { id("com.gradleup.librarian").apply(false)}
Librarian.root(project)
2/4 Root project configuration
Add a librarian.root.properties
file to the root of your repository:
# Common information for your repositorypom.groupId=com.examplepom.version=0.0.7-SNAPSHOTpom.description=Cool librarypom.vcsUrl=https://github.com/example/coolpom.developer=Cool library authorspom.license=MIT
# Optional: publish to Google Cloud Storagegcs.bucket=gradleupgcs.prefix=m2
# Optional: configure compatibilityjava.compatibility=11kotlin.compatibility=2.0.0
# Optional: publish older versions of the Kdoc (requires them to be already published)kdoc.olderVersions=1.0.0,2.0.0
3/4 Project specific configuration
Configure librarian in each subproject:
plugins { // no need to add librarian here, it's already on the classpath}
// Configure librarianLibrarian.module(project)
4/4 Add the signing and publishing secrets
Add secrets to your environment:
export LIBRARIAN_SONATYPE_PASSWORD=...export LIBRARIAN_SONATYPE_USERNAME=...export LIBRARIAN_SIGNING_PRIVATE_KEY=...export LIBRARIAN_SIGNING_PRIVATE_KEY_PASSWORD=...export LIBRARIAN_GOOGLE_SERVICES_JSON=...
You can now publish the library!
Publish your library:
./gradlew librarianPublishToMavenCentral./gradlew librarianPublishToMavenSnapshots./gradlew librarianPublishToGcs