How to import helper class in buildSrc/build.gradle.kts, settings.gradle.kts, and build.gradle.kts?

I’d like to create a class to help me loading different types of properties (,, $GRADLE_HOME/, environment variables, system properties, and custom properties files (maybe in other formats like yml, xml, etc.).

Also, I’d like to use this in my buildSrc/build.gradle.kts, settings.gradle.kts, and build.gradle.kts.

Please consider that we are using Gradle 6.+.

A simple implementation of this class would be (the full implementation would be a lot of more powerful):


package com.example

object Properties {
	val environmentVariables = System.getenv()

How can we successfully import this Properties class in all of those files (buildSrc/build.gradle.kts, settings.gradle.kts, build.gradle.kts) and use it from there? Something like:


Can we do that creating this class inside of a plugin and applying it from there? Without pre-compiling and releasing the plugin? Maybe something like:


I tried different approaches but I’m not being able to find a way that work with those 3 files altogether.