Class EnhancedProblems

java.lang.Object
groovy.lang.GroovyObjectSupport
net.minecraftforge.gradleutils.shared.EnhancedProblems
All Implemented Interfaces:
GroovyObject, Predicate<String>, Problems

public abstract class EnhancedProblems extends GroovyObjectSupport implements Problems, Predicate<String>
The enhanced problems contain several base helper members to help reduce duplicate code between Gradle plugins.
  • Field Details

  • 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

    • getReporter

      public ProblemReporter getReporter()
      Specified by:
      getReporter in interface Problems
    • getProblemGroup

      public final ProblemGroup getProblemGroup()
      Gets the problem group used by this problems instance. It is unique for the plugin.
      Returns:
      The problem group
    • id

      protected final ProblemId id(String name, String displayName)
      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
    • illegalPluginTarget

      public final RuntimeException illegalPluginTarget(Exception e, Class<?> firstAllowedTarget, Class<?>... allowedTargets)
      Reports an illegal plugin target.
      Parameters:
      e - The exception that was caught, will be re-thrown (or wrapped with a RuntimeException)
      firstAllowedTarget - The first allowed target for the plugin
      allowedTargets - The remaining allowed targets for the plugin
      Returns:
      The exception to throw
    • illegalPluginTarget

      public final RuntimeException illegalPluginTarget(Exception e, String allowedTargets)
      Reports an illegal plugin target.
      Parameters:
      e - The exception that was caught, will be re-thrown (or wrapped with a RuntimeException)
      allowedTargets - A string stating the allowed targets for the plugin
      Returns:
      The exception to throw
    • pluginNotYetApplied

      public final RuntimeException pluginNotYetApplied(Exception e)
      Reports an illegal access of a plugin before it has been applied.
      Parameters:
      e - The exception that was caught, will be re-thrown (or wrapped with a RuntimeException)
      Returns:
      The exception to throw
    • reportToolExecNotEnhanced

      public final void reportToolExecNotEnhanced(Task task)
      Reports an implementation of ToolExecBase that is not enhanced with EnhancedTask.
      Parameters:
      task - The affected task
    • reportToolExecNotEnhanced

      public final void reportToolExecNotEnhanced(Class<?> task)
      Reports an implementation of EnhancedTask that does not implement EnhancedTask.pluginType()
      Parameters:
      task - The affected task
    • reportToolExecEagerArgs

      public final void reportToolExecEagerArgs(Task task)
      Reports an implementation of ToolExecBase that adds arguments without using ToolExecBase.addArguments()
      Parameters:
      task - The affected task
    • ensureFileLocation

      public final <T extends FileSystemLocation> 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
    • getProblems

      @Inject protected Problems getProblems()
      The problems instance provided by Gradle services.
      Returns:
      The problems instance
      See Also:
    • getProviders

      @Inject protected ProviderFactory getProviders()
      The provider factory provided by Gradle services.
      Returns:
      The provider factory
      See Also:
    • invokeMethod

      public Object invokeMethod(String name, Object args)
      Specified by:
      invokeMethod in interface GroovyObject
    • getProperty

      public Object getProperty(String propertyName)
      Specified by:
      getProperty in interface GroovyObject