A simple function for Kotlin that can be used in unit tests to set environment variables for the current instance of Java.
Note that this only works for Java 17+
In your gradle file
Follow this guide on how to set up your environment for GitHub packages.
plugins {
id("no.ghpkg") version "0.3.3"
}
repositories {
git.hub("telenornorway", "setenv.kt")
// or <.. the below> if you're spicy 🌶️
// git.hub("telenornorway")
}
dependencies {
testImplementation("no.telenor.kt:setenv:<VERSION HERE>")
}
import no.telenor.kt.env.Environment
Environment.set("my variable", "my value")
Environment.set(
"my variable 1" to "my value 1",
"my variable 2" to "my value 2",
)