project-environment-version
= 1.0.0
This plugin automatically loads the environment variable files (*.env
) as well as the system environment variables.
Access to these environment variables is done in the same way as with the native gradle
extension org.gradle.api.plugins.ExtraPropertiesExtension
:
// Kotlin DSL
val element = projectEnv["ENV_NAME"] // -> Optional<String>
val elementWithDefaultValue = projectEnv["ENV_OPT_NAME", "Default Value"] // -> java.lang.String
// Groovy DSL
var element = projectEnv.get("ENV_NAME") // -> Optional<String>
var elementWithDefaultValue = projectEnv.get("ENV_OPT_NAME", "Default Value") // -> java.lang.String
To use the plugin you need to add the plugin to Gradle:
// Kotlin DSL
plugins {
id("io.github.uoxx3.project-environment") version "[project-environment-version]"
}
// Groovy DSL
plugins {
id 'io.github.uoxx3.project-environment' version '[project-environment-version]'
}