You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

This sample shows how problems can be emitted via the Problems API and how those reports are consumed on the IDE-side.

Running the sample

To run the sample, execute the ./gradlew :sample-ide:importBuild command.

Project structure

The sample consists of multiple, individual builds composed into a composite build with the following layout

  • sample-project: A Gradle build with plugins that report problems

  • sample-ide: a project that simulates the IDE functionality. In other words, it uses the Gradle Tooling API to configure and run the sample-project build and prints the received problem reports received during the process.

  • reporters/standard-plugin shows the usage of the Problems API in a standard Gradle plugin.

  • reporters/model-builder-plugin shows how to use the Problems API to report problems when reading project configuration via the Tooling API.

  • reporters/script-plugin shows how to use the Problems API in a precompiled script plugin.

Emitting a problem

Problems can be emitted via an injected Problems service. Here’s an example on how to report a problem from a plugin.

problems.forNamespace("reporters.standard.plugin").reporting(problem -> problem
        .label("The 'standard-plugin' is deprecated")
        .category("deprecation", "plugin")
        .solution("Please use a more recent plugin version")

Receiving a problem report

Problems are emitted as Tooling API progress events. They can be processed by registering a ProgressListener:

public void statusChanged(ProgressEvent progressEvent) {
    prettyPrint(((ProblemDescriptor) progressEvent.getDescriptor()));