Gradle Tooling API: create a Gradle build without physically creating the file

The documentation for Gradle Tooling API explains how to run builds using an actual existing build.gradle file (or, rather, the project directory). Gradle also provides testfixtures package and a ProjectBuilder util class that can be used to create a ‘dummy instance’, as the docs put it, of Project that can be built in tests, and this doesn’t create any actual permanent build files.

What if I need to launch a Gradle plugin programmatically, from the code of another application (an IDE in this particular case)? Can this be done without creating a separate build.gradle file which applies my plugin? I’m led to believe ProjectBuilder should be used for Gradle plugin testing and not what I’m trying to do here. Can i construct a build without creating an actual file, even if that file is temporary?

And how do I get Gradle aware of my plugin? I tried to use ProjectBuilder.builder().build().pluginManager.apply() for a plugin published in the Gradle plugin repository, but I’m getting a org.gradle.api.plugins.UnknownPluginException: Plugin with id '...' not found.