Class SharedUtil

java.lang.Object
net.minecraftforge.gradleutils.shared.SharedUtil

public abstract class SharedUtil extends Object
Shared utilities for Gradle plugins.
  • Constructor Details

    • SharedUtil

      protected SharedUtil()
      Empty constructor. This class should only be extended to make referencing these static methods easier.
  • Method Details

    • launcherFor

      public static Provider<JavaLauncher> launcherFor(JavaPluginExtension java, JavaToolchainService javaToolchains, int version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      java - The Java plugin extension of the currently-used toolchain
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherFor

      public static Provider<JavaLauncher> launcherFor(JavaPluginExtension java, JavaToolchainService javaToolchains, JavaLanguageVersion version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      java - The Java plugin extension of the currently-used toolchain
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherFor

      public static Provider<JavaLauncher> launcherFor(Provider<? extends JavaPluginExtension> java, Provider<? extends JavaToolchainService> javaToolchains, int version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      java - The Java plugin extension of the currently-used toolchain
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherFor

      public static Provider<JavaLauncher> launcherFor(Provider<? extends JavaPluginExtension> java, Provider<? extends JavaToolchainService> javaToolchains, JavaLanguageVersion version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      java - The Java plugin extension of the currently-used toolchain
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherFor

      public static Provider<JavaLauncher> launcherFor(Project project, int version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      project - The project to get the Java extensions from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherFor

      public static Provider<JavaLauncher> launcherFor(Project project, JavaLanguageVersion version)

      Gets the Java launcher that can compile or run the given version.

      If the currently running Java toolchain is able to compile and run the given version, it will be used instead.

      Parameters:
      project - The project to get the Java extensions from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(JavaToolchainService javaToolchains, int version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(JavaToolchainService javaToolchains, JavaLanguageVersion version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(Provider<? extends JavaToolchainService> javaToolchains, int version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(Provider<? extends JavaToolchainService> javaToolchains, JavaLanguageVersion version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      javaToolchains - The Java toolchain service to get the Java launcher from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(Project project, int version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      project - The extension-aware object to get the Java extensions from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • launcherForStrictly

      public static Provider<JavaLauncher> launcherForStrictly(Project project, JavaLanguageVersion version)
      Gets the Java launcher strictly for the given version, even if the currently running Java toolchain is higher than it.
      Parameters:
      project - The extension-aware object to get the Java extensions from
      version - The version of Java required
      Returns:
      A provider for the Java launcher
    • ensureAfterEvaluate

      public static void ensureAfterEvaluate(Project project, @DelegatesTo(value=Project.class,strategy=1) Closure<?> closure)
      Runs the given closure using Project.afterEvaluate(Action). If the project is already executed, the closure will be called instantly.
      Parameters:
      project - The project to run the closure on
      closure - The closure to execute
    • ensureAfterEvaluate

      public static void ensureAfterEvaluate(Project project, Action<? super Project> action)
      Runs the given action using Project.afterEvaluate(Action). If the project is already executed, the action will be executed instantly.
      Parameters:
      project - The project to run the action on
      action - The action to execute
    • toLog

      public static OutputStream toLog(Action<? super String> logger)
      Creates an output stream that logs to the given action.
      Parameters:
      logger - The logger to log to
      Returns:
      The output stream
    • toString

      public static String toString(ModuleVersionSelector module)
      Converts a given module to string. Use this instead of Object.toString().
      Parameters:
      module - The module
      Returns:
      The string representation
    • toString

      public static String toString(Dependency dependency)
      Converts a given dependency to string. Use this instead of Object.toString().
      Parameters:
      dependency - The dependency
      Returns:
      The string representation