Getting a VisualCppPlatformToolChain, VisualStudioLocator or WindowsSdkLocator instance

We’re in the process of migrating our native projects to Gradle (including publishing artifacts to a repository), so we also need to publish external dependencies to a repository (as there’s no public repositroy equivalent to Maven central repo).
For this we need to compile the external dependencies and chose to do a ‘light’ Gradle build, i.e. not a full Gradle build with native components, but only call the existing build and publish the binaries.
Some of the projects use VisualStudio and as such we need to detect where it is located (as the way to detect this is not trivial). Gradle has classes that fill this need, but I don’t know how to get an instance of these classes. Is it possible?

Edit: added VisualCppPlatformToolChain, as this one is a public API.