How to access information of a Gradle project from a standalone program?

I am improving a Kotlin debug adapter used for e.g. VS Code:

However, I meet a problem related to access information from a Gradle project. For a Spring Boot Kotlin Gradle project, to correctly launch the built Spring Boot application, we have to pass full classpaths to java executable, including build/classes/kotlin/main, build/resources/main, etc.
By the document
the classpath build/resources/main is from Gradle Java plugin, and it may contain a file,, used by Spring Boot. Thus, this classpath is required by kotlin-debug-adapter to launch a Spring Boot application for debugging. My problem is how a standalone program (not a Gradle plugin), like kotlin-debug-adapter (written in Kotlin), can get these classpaths from a Gradle project. I studied Gradle Java API documents but don’t know to load a Gradle project and access its information including classpaths. Is there any API for that?

The Gradle Tooling API allows you to query the project for a model. The model is provided by a plugin, which you can inject/apply using an init script that you specify on the command line. The command line can be modified using a ModelBuilder returned from ProjectConnection.model(Class).

This is not a well documented topic, so it’s going to take some experimentation and digging.
Benjamin Muschko has an example that might help get you started.

Thank you. I will try it.

I finish my plugin for acquiring a Gradle project information for another standalone program. Its repo is here:

It contains an example folder to use this plugin.