Class EnhancedPlugin<T>

java.lang.Object
net.minecraftforge.gradleutils.shared.EnhancedPlugin<T>
Type Parameters:
T - The type of target
All Implemented Interfaces:
org.gradle.api.Plugin<T>

@OverrideOnly public abstract class EnhancedPlugin<T> extends Object implements org.gradle.api.Plugin<T>
The enhanced plugin contains several helper members to assist in making Gradle plugins as clean as possible without needing to duplicate code across projects.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    EnhancedPlugin(String name, String displayName)
    This constructor must be called by all subclasses using a public constructor annotated with Inject.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    apply(T target)
    This method is used by Gradle to apply this plugin.
    protected abstract org.gradle.api.model.ObjectFactory
     
    protected abstract org.gradle.api.provider.ProviderFactory
     
    org.gradle.api.provider.Provider<File>
    getTool(Tool tool)
    Gets a provider to the file for a Tool to be used.
    final org.gradle.api.file.DirectoryProperty
    Gets the global caches to be used for this plugin.
    final org.gradle.api.file.DirectoryProperty
    Gets the local caches to be used for this plugin.
    abstract void
    setup(T target)
    Called when this plugin is applied to do setup work.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EnhancedPlugin

      protected EnhancedPlugin(String name, String displayName)
      This constructor must be called by all subclasses using a public constructor annotated with Inject. The name and display name passed in are used in a minimal instance of EnhancedProblems, which is used to set up the plugin's global and local caches. Additionally, the name is used to create the cache folders (minecraftforge/name).
      Parameters:
      name - The name for this plugin (must be machine-friendly)
      displayName - The display name for this plugin
  • Method Details

    • getObjects

      @Inject protected abstract org.gradle.api.model.ObjectFactory getObjects()
      See Also:
    • getProviders

      @Inject protected abstract org.gradle.api.provider.ProviderFactory getProviders()
      See Also:
    • apply

      public final void apply(T target)
      This method is used by Gradle to apply this plugin. You should instead override setup(T) to do plugin setup.
      Specified by:
      apply in interface org.gradle.api.Plugin<T>
      Parameters:
      target - The target for this plugin
    • setup

      public abstract void setup(T target)
      Called when this plugin is applied to do setup work.
      Parameters:
      target - The target for this plugin (can also get after setup with getTarget())
    • getTool

      public org.gradle.api.provider.Provider<File> getTool(Tool tool)
      Gets a provider to the file for a Tool to be used. The tool's state is managed by Gradle through the ValueSource API and will not cause caching issues.
      Parameters:
      tool - The tool to get
      Returns:
      A provider for the tool file
    • globalCaches

      public final org.gradle.api.file.DirectoryProperty globalCaches()

      Gets the global caches to be used for this plugin. These caches persist between projects and should be used to eliminate excess work done by projects that request the same data.

      It is stored in ~/.gradle/caches/minecraftforge/plugin.

      Returns:
      The global caches
      Throws:
      RuntimeException - If this plugin cannot access global caches (i.e. the target is not Project or Settings)
    • localCaches

      public final org.gradle.api.file.DirectoryProperty localCaches()

      Gets the local caches to be used for this plugin. Data done by tasks that should not be shared between projects should be stored here.

      It is located in project/build/minecraftforge/plugin.

      Returns:
      The global caches
      Throws:
      RuntimeException - If this plugin cannot access global caches (i.e. the target is not Project or Settings)