Skip to content

TarasovVP/KMP-Secrets-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KMP Secrets Plugin

Gradle plugin that turns key-value pairs from local.properties into a type-safe Kotlin object for Kotlin Multiplatform projects.

Group/ID: io.github.tarasovvp : kmp-secrets-plugin
Latest: Maven Central
License: Apache-2.0


Installation

1. Configure repositories

Add to your settings.gradle.kts file:

pluginManagement {
    repositories {
        mavenCentral()
        gradlePluginPortal()
        google()
    }
}

2. Apply the plugin

Add to your module's build.gradle.kts (only where needed):

plugins {
    id("org.jetbrains.kotlin.multiplatform")
    id("io.github.tarasovvp.kmp-secrets-plugin") version "1.2.0"
}

Quick Start

  1. Put secrets in local.properties of the same module
    (the root file is used only if the module file is absent)
API_KEY=your_key
DEBUG=true
  1. Build the project with any compile/assemble task, e.g.:
./gradlew assemble
  1. The plugin generates the file
    <moduleDir>/<outputDir>/secrets/Secrets.kt

    • By default, outputDir is src/commonMain/kotlin, so the file is created at
      <moduleDir>/src/commonMain/kotlin/secrets/Secrets.kt.
    • If you override outputDir in the secrets { … } block, the file will be created in that custom location, e.g.:
secrets {
    outputDir = "$projectDir/generatedSecrets"
}
  1. Git ignore is handled automatically
  • If a .gitignore exists, the relative path to Secrets.kt is appended.
  • If none exists, the plugin creates one with the path included.

Your secrets will never be committed by mistake.


Notes

Preferred format:

API_KEY=sample_secret_data

With special characters:

QUOTED=He said "Hello"
WINDOWS_PATH=C:\Tools\bin

Becomes:

object Secrets { 
    const val QUOTED = "He said \"Hello\"" 
    const val WINDOWS_PATH = "C:\\Tools\\bin" 
}

Compatibility

  • Gradle 8.2+
  • Kotlin 1.9/2.x
  • Android/iOS/Desktop/Web targets

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages