Class EnhancedPlugin<T>

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

public abstract non-sealed class EnhancedPlugin<T> extends Object implements org.gradle.api.Plugin<T>, EnhancedPluginAdditions
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.
    protected
    EnhancedPlugin(String name, String displayName, @Nullable String toolsExtName)
    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.file.BuildLayout
    The build layout provided by Gradle services.
    protected abstract org.gradle.jvm.toolchain.JavaToolchainService
    The Java toolchain service provided by Gradle services.
    protected abstract org.gradle.api.model.ObjectFactory
    The object factory provided by Gradle services.
    protected abstract org.gradle.api.file.ProjectLayout
    The project layout provided by Gradle services.
    protected abstract org.gradle.api.provider.ProviderFactory
    The provider factory provided by Gradle services.
    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.
    final org.gradle.api.file.DirectoryProperty
    Gets the root project directory to be used for this plugin.
    abstract void
    setup(T target)
    Called when this plugin is applied to do setup work.
    final org.gradle.api.file.DirectoryProperty
    Gets the working project directory to be used for this plugin.

    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
    • EnhancedPlugin

      protected EnhancedPlugin(String name, String displayName, @Nullable @Nullable String toolsExtName)
      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
      toolsExtName - The name for the tools extension to used, or null if it should not be created
  • Method Details

    • getObjects

      @Inject protected abstract org.gradle.api.model.ObjectFactory getObjects()
      The object factory provided by Gradle services.
      Returns:
      The object factory
      See Also:
    • getProjectLayout

      @Inject protected abstract org.gradle.api.file.ProjectLayout getProjectLayout()
      The project layout provided by Gradle services.
      Returns:
      The build layout
      See Also:
    • getBuildLayout

      @Inject protected abstract org.gradle.api.file.BuildLayout getBuildLayout()
      The build layout provided by Gradle services.
      Returns:
      The build layout
      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:
    • getJavaToolchains

      @Inject protected abstract org.gradle.jvm.toolchain.JavaToolchainService getJavaToolchains()
      The Java toolchain service provided by Gradle services.
      Returns:
      The Java toolchain service
    • 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 Tool.Resolved getTool(Tool tool)
      Description copied from interface: EnhancedPluginAdditions
      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.
      Specified by:
      getTool in interface EnhancedPluginAdditions
      Parameters:
      tool - The tool to get
      Returns:
      A provider for the tool file
    • globalCaches

      public final org.gradle.api.file.DirectoryProperty globalCaches()
      Description copied from interface: EnhancedPluginAdditions

      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.

      Specified by:
      globalCaches in interface EnhancedPluginAdditions
      Returns:
      The global caches
    • localCaches

      public final org.gradle.api.file.DirectoryProperty localCaches()
      Description copied from interface: EnhancedPluginAdditions

      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.

      Specified by:
      localCaches in interface EnhancedPluginAdditions
      Returns:
      The global caches
    • rootProjectDirectory

      public final org.gradle.api.file.DirectoryProperty rootProjectDirectory()
      Description copied from interface: EnhancedPluginAdditions

      Gets the root project directory to be used for this plugin.

      This directory is either the ProjectLayout.getProjectDirectory() of Project.getRootProject() or the BuildLayout.getRootDirectory() of the Settings. Attempting to call this when the plugin target is neither type will throw an exception.

      Specified by:
      rootProjectDirectory in interface EnhancedPluginAdditions
      Returns:
      The root project directory
    • workingProjectDirectory

      public final org.gradle.api.file.DirectoryProperty workingProjectDirectory()
      Description copied from interface: EnhancedPluginAdditions

      Gets the working project directory to be used for this plugin.

      This directory is either the ProjectLayout.getProjectDirectory() of the Project or the BuildLayout.getRootDirectory() of the Settings. Attempting to call this when the plugin target is neither type will throw an exception.

      Specified by:
      workingProjectDirectory in interface EnhancedPluginAdditions
      Returns:
      The working project directory