This simple plugin allows you to load properties (such as API keys)
from .properties
files into project extras.
First of all, load plugin in your root project's build.gradle
file:
plugins {
id "io.github.fobo66.propertiesloader" version "1.0"
}
For Kotlin DSL:
plugins {
id("io.github.fobo66.propertiesloader") version "1.0"
}
Then you need to specify .properties
files for the plugin:
propertiesLoader {
propertiesFiles.from(project.file("api.properties"))
}
Given api.properties
has the following content:
testkey=CHANGE_ME
Then you can access testkey
via project extras in your tasks. In Groovy DSL:
ext.testkey
// or for task context
project.ext.testkey
For Kotlin DSL:
val testkey : String by extra
// or for task context
val testkey = project.extensions.extraProperties.get("testkey")
To see an example of how to use this plugin, see functional tests. There are all the needed properties defined in test cases in build.gradle
"files".