Class ProblemId

java.lang.Object
org.gradle.api.problems.ProblemId

@Incubating public abstract class ProblemId extends Object
Represents a unique identifier for a problem definition.

Problem IDs are defined with a name and with group hierarchy. For example, in the domain of Java compilation problems, the id object for unused variable warnings would be:

ProblemId(name: Unused variable, group:
    ProblemGroup(name: Java, parent:
        ProblemGroup(name: Compilation, parent: null)))
Such an id is created from the predefined groups, see Problems.getGroups(): getGroups().getCompilation().getJava().problemId("Unused variable"). Consumers of problem reports can build a tree representation of problems from the names:
(Problem view)
Compilation
    Java
        Foo.java#L10: unused variable a
        Foo.java#L20: unused variable b
Since:
8.13
See Also:
  • Constructor Details

    • ProblemId

      @Deprecated protected ProblemId()
      Deprecated.
      Subclassing ProblemId outside of Gradle is deprecated and will not be supported in Gradle 10. Use the groups from Problems.getGroups() instead.
      Constructor.
      Since:
      8.13
  • Method Details

    • getName

      public abstract String getName()
      The name of the problem.

      Then name should be used categorize to create a fully qualified name and to categorize a set of problems. The name itself does not need to be unique, the uniqueness is determined the name and the group hierarchy.

      Since:
      8.13
    • getDisplayName

      @Deprecated public abstract String getDisplayName()
      Deprecated.
      Use getName() instead. The display name of an id created from a group of Problems.getGroups() is its name. This method will be removed in Gradle 10.
      A human-readable label describing the problem ID.

      The display name should be used to present the problem to the user.

      Since:
      8.13
    • getGroup

      public abstract ProblemGroup getGroup()
      The parent group.
      Since:
      8.13
    • create

      @Deprecated public static ProblemId create(String name, String displayName, ProblemGroup group)
      Deprecated.
      Create the id from a predefined group of Problems.getGroups() instead, with SecondLevelProblemGroup.problemId(String), ThirdLevelProblemGroup.problemId(String) or UndefinedProblemGroup.problemId(String). This method will be removed in Gradle 11.
      Creates a new problem id.
      Parameters:
      name - the name of the problem. Cannot be blank (i.e., null, empty string, or only whitespaces).
      displayName - the user-friendly display name of the problem. Cannot be blank (i.e., null, empty string, or only whitespaces).
      group - the group to which the problem belongs. Cannot be null.
      Returns:
      the new problem id
      Since:
      8.13