Skip to content

Instantly share code, notes, and snippets.

@Flying--Dutchman
Flying--Dutchman / GradleReadProperty.kts
Last active January 21, 2023 13:49
Easily read a property from gradle.properties and local.properties
// From my Codeberg page: https://codeberg.org/FlyingDutchman/GradleReadProperty/src/branch/main/getSetting
// Simply copy following code in your gradle.build.kts file
// Also use the following imports: java.io.File and import java.util.*
fun getSetting(key: String) = project.getSetting(key)
fun Project.getSetting(key: String): String {
// Check if local properties
val localProperty = rootProject.file("local.properties")
if (localProperty.isFile) {