Class EnhancedProblems

java.lang.Object
net.minecraftforge.gradleutils.shared.EnhancedProblems
All Implemented Interfaces:
Serializable, Predicate<String>

public abstract class EnhancedProblems extends Object implements Serializable, Predicate<String>
The enhanced problems contain several base helper members to help reduce duplicate code between Gradle plugins.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    The common message to send in ProblemSpec.solution(String) when reporting problems.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    EnhancedProblems(String name, String displayName)
    Creates a new enhanced problems instance using the given name and display name.
  • Method Summary

    Modifier and Type
    Method
    Description
    final <T extends org.gradle.api.file.FileSystemLocation>
    org.gradle.api.Transformer<T,T>
    A utility method to ensure that a FileSystemLocation Provider has (its parent) directory created.
    final org.gradle.api.problems.Problems
    Gets the problems instance used by this enhanced problems.
    protected final org.gradle.api.logging.Logger
    Gets the logger to be used by this enhanced problems.
    final org.gradle.api.problems.ProblemGroup
    Gets the problem group used by this enhanced problems.
    protected abstract org.gradle.api.problems.Problems
    Deprecated.
    Does not handle if Problems API cannot be accessed.
    protected abstract org.gradle.api.provider.ProviderFactory
    The provider factory provided by Gradle services.
    protected final org.gradle.api.problems.ProblemReporter
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected final org.gradle.api.problems.ProblemId
    id(String name, String displayName)
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected final void
    report(String name, String displayName, org.gradle.api.Action<? super org.gradle.api.problems.ProblemSpec> spec)
    Reports an issue using the give name and display name as the ProblemId and the given spec to create the Problem.
    final boolean
    test(String property)
    Checks if the given property exists and equals true.
    final boolean
    testFalse(String property)
    Checks if the given property exists and equals false.
    protected final RuntimeException
    throwing(Throwable exception, String name, String displayName, org.gradle.api.Action<? super org.gradle.api.problems.ProblemSpec> spec)
    Reports an issue much like report(String, String, Action), but also returns the given exception to be thrown by the calling class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Predicate

    and, negate, or
  • Field Details

    • HELP_MESSAGE

      protected static final String HELP_MESSAGE
      The common message to send in ProblemSpec.solution(String) when reporting problems.
      See Also:
  • Constructor Details

    • EnhancedProblems

      protected EnhancedProblems(String name, String displayName)
      Creates a new enhanced problems instance using the given name and display name. These names are passed into a problem group that will be used by this instance.
      Parameters:
      name - The name for this enhanced problems instance
      displayName - The display name for this enhanced problems instance
      Implementation Requirements:
      The implementing subclass must make their constructor public, annotated with Inject, and have no parameters, passing in static strings to this base constructor.
  • Method Details

    • getProblems

      @Deprecated @Inject protected abstract org.gradle.api.problems.Problems getProblems()
      Deprecated.
      Does not handle if Problems API cannot be accessed. Use getDelegate().
      The problems instance provided by Gradle services.
      Returns:
      The problems instance
      See Also:
    • getProviders

      @Inject protected abstract org.gradle.api.provider.ProviderFactory getProviders()
      The provider factory provided by Gradle services.
      Returns:
      The provider factory
      See Also:
    • getDelegate

      public final org.gradle.api.problems.Problems getDelegate()
      Gets the problems instance used by this enhanced problems.
      Returns:
      The delegate problems instance
    • getReporter

      @Deprecated(forRemoval=true, since="3.2.26") protected final org.gradle.api.problems.ProblemReporter getReporter()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the problem reporter used by the delegate problems instance.
      Returns:
      The problem reporter
    • getProblemGroup

      public final org.gradle.api.problems.ProblemGroup getProblemGroup()
      Gets the problem group used by this enhanced problems. It is unique for the plugin.
      Returns:
      The problem group
    • getLogger

      protected final org.gradle.api.logging.Logger getLogger()
      Gets the logger to be used by this enhanced problems.
      Returns:
      The logger
    • report

      protected final void report(String name, String displayName, org.gradle.api.Action<? super org.gradle.api.problems.ProblemSpec> spec)
      Reports an issue using the give name and display name as the ProblemId and the given spec to create the Problem.
      Parameters:
      name - The name of the problem
      displayName - The display name of the problem
      spec - The details to use when creating the problem
      See Also:
    • throwing

      protected final RuntimeException throwing(Throwable exception, String name, String displayName, org.gradle.api.Action<? super org.gradle.api.problems.ProblemSpec> spec)
      Reports an issue much like report(String, String, Action), but also returns the given exception to be thrown by the calling class.
      Parameters:
      exception - The exception to throw
      name - The name of the problem
      displayName - The display name of the problem
      spec - The details to use when creating the problem
      Returns:
      The exception to be thrown by the calling class
      See Also:
      API Note:
      Due to a bug in Gradle, any exceptions that do not extend RuntimeException will be wrapped inside one. While this pollutes the stacktrace, it keeps the details of the problem in view for terminal and IDE users.
    • id

      @Deprecated(forRemoval=true, since="3.2.26") protected final org.gradle.api.problems.ProblemId id(String name, String displayName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a problem ID to be used when reporting problems. The name must be unique so as to not potentially override other reported problems in the report.
      Parameters:
      name - The name for this problem
      displayName - The display name for this problem
      Returns:
      The problem ID
    • test

      public final boolean test(String property)

      Checks if the given property exists and equals true.

      This checks both Gradle and System properties, giving the former higher priority. If for some reason a provider factory is not available in the current environment, Boolean.getBoolean(String) will be used instead.

      Specified by:
      test in interface Predicate<String>
      Parameters:
      property - The property to test
      Returns:
      If the property exists and is true
    • testFalse

      public final boolean testFalse(String property)

      Checks if the given property exists and equals false.

      This checks both Gradle and System properties, giving the former higher priority. If for some reason a provider factory is not available in the current environment, Boolean.getBoolean(String) will be used instead.

      Parameters:
      property - The property to test
      Returns:
      If the property exists and is false
    • ensureFileLocation

      public final <T extends org.gradle.api.file.FileSystemLocation> org.gradle.api.Transformer<T,T> ensureFileLocation()
      A utility method to ensure that a FileSystemLocation Provider has (its parent) directory created. If the directory cannot be created, an exception will be thrown when the provider that consumes this is resolved.
      Type Parameters:
      T - The type of file system location (i.e. RegularFile or Directory)
      Returns:
      The transformer to apply onto a provider