Gradle kotlindsl extract logic to outer scripts

What is the recommended way to extract gradle build code blocks to external scripts? Notice these scripts should support references to the gradle project, extra etc. So - compiling kt files in buildSrc isn’t what I’m looking for.

I’ve tried to create files like logger.gradle.kts and these seem to “know” the project ref / compile, but any fun I write in them is not referenceable in the main build file although I apply like this:

apply (from = "logger.gradle.kts")

The error I get as part of the build is:

Unresolved reference: logInfo - where logInfo is a fun in logger.gradle.kts .

Followed this and it worked: