Class EnhancedPlugin<T>

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

public abstract class EnhancedPlugin<T> extends Object implements 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 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 ObjectFactory getObjects()
      See Also:
    • getBuildLayout

      @Inject protected abstract BuildLayout getBuildLayout()
      See Also:
    • getProviders

      @Inject protected abstract 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 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 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 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 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)