Groovy Scripts - Reusable Code
Let's start with the following Groovy script which reads and prints all the properties from a file.
import java.nio.file.Path
Properties loadProperties() {
Properties properties = new Properties()
Path propertyFilePath = Path.of('my.properties')
propertyFilePath.withInputStream { properties.load(it) }
properties
}
Properties properties = loadProperties()
properties.each { println