Interface Tool

All Superinterfaces:
org.gradle.api.Named, Serializable
All Known Subinterfaces:
Tool.Resolved

public sealed interface Tool extends org.gradle.api.Named, Serializable permits Tool.Resolved (not exhaustive)
Tools are definitions of Java libraries (may or may not be executable) that are managed by Gradle using a ValueSource. This means that while the downloading and local caching of this file are done in house, the Gradle-specific caching and file tracking are done by Gradle. This enables the usage of downloading external files quickly without breaking caches.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A definition of how a tool should be resolved and used by the plugin.
    static interface 
    A resolved tool that has a classpath that can be readily used.

    Nested classes/interfaces inherited from interface org.gradle.api.Named

    org.gradle.api.Named.Namer
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The Java version this tool was built with.
    @Nullable String
    The main class to use when executing this tool.
    @Nullable String
    The main module to use when executing this tool.
    org.gradle.api.artifacts.ModuleVersionIdentifier
    The module for this tool.
    The name for this tool.
    default boolean
    If this tool has a strictly defined main class.
    default boolean
    If this tool has a strictly defined main module.
    static Tool
    of(String name, String artifact, String mavenUrl, int javaVersion)
    Creates a new tool with the given information.
    static Tool
    of(String name, String artifact, String mavenUrl, int javaVersion, @Nullable String mainClass)
    Creates a new tool with the given information.
    static Tool
    of(String name, String artifact, String mavenUrl, int javaVersion, String mainClass, String mainModule)
    Creates a new tool with the given information.
    static Tool
    ofForge(String name, String artifact, int javaVersion)
    Creates a new tool with the given information.
    static Tool
    ofForge(String name, String artifact, int javaVersion, String mainClass)
    Creates a new tool with the given information.
    static Tool
    ofForge(String name, String artifact, int javaVersion, String mainClass, String mainModule)
    Creates a new tool with the given information.
  • Method Details

    • of

      static Tool of(String name, String artifact, String mavenUrl, int javaVersion, String mainClass, String mainModule)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      mavenUrl - The maven URL this tool is hosted on (if protocol is omitted, prepends https://, and appends adds trailing slash if missing)
      javaVersion - The Java version this tool was built with, or should run on
      mainClass - The main class to use when executing this tool
      mainModule - The main module to use when executing this tool
      Returns:
      The tool
    • of

      static Tool of(String name, String artifact, String mavenUrl, int javaVersion, @Nullable @Nullable String mainClass)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      mavenUrl - The maven URL this tool is hosted on (if protocol is omitted, prepends https://, and appends adds trailing slash if missing)
      javaVersion - The Java version this tool was built with, or should run on
      mainClass - The main class to use when executing this tool (optional)
      Returns:
      The tool
    • of

      static Tool of(String name, String artifact, String mavenUrl, int javaVersion)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      mavenUrl - The maven URL this tool is hosted on (if protocol is omitted, prepends https://, and appends adds trailing slash if missing)
      javaVersion - The Java version this tool was built with, or should run on
      Returns:
      The tool
    • ofForge

      static Tool ofForge(String name, String artifact, int javaVersion, String mainClass, String mainModule)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      javaVersion - The Java version this tool was built with, or should run on
      mainClass - The main class to use when executing this tool
      mainModule - The main module to use when executing this tool
      Returns:
      The tool
    • ofForge

      static Tool ofForge(String name, String artifact, int javaVersion, String mainClass)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      javaVersion - The Java version this tool was built with, or should run on
      mainClass - The main class to use when executing this tool (optional)
      Returns:
      The tool
    • ofForge

      static Tool ofForge(String name, String artifact, int javaVersion)
      Creates a new tool with the given information.
      Parameters:
      name - The name for this tool, used to reference it in configuration and for the file name
      artifact - The artifact for this tool, used to get the download URL
      javaVersion - The Java version this tool was built with, or should run on
      Returns:
      The tool
    • getModule

      org.gradle.api.artifacts.ModuleVersionIdentifier getModule()
      The module for this tool.
      Returns:
      The module for this tool
    • getName

      String getName()
      The name for this tool. Primarily used by ToolExecBase to create a default tool directory.
      Specified by:
      getName in interface org.gradle.api.Named
      Returns:
      The name of this tool
    • getJavaVersion

      int getJavaVersion()
      The Java version this tool was built with. Primarily used by ToolExecBase to determine the JavaLauncher.
      Returns:
      The Java version
    • getMainClass

      @Nullable @Nullable String getMainClass()
      The main class to use when executing this tool. Can be null, but does not necessarily mean that the tool is not executable.
      Returns:
      The main class, or null if unspecified
    • hasMainClass

      default boolean hasMainClass()
      If this tool has a strictly defined main class. Can be false, but does not necessarily mean that this tools is not executable.
      Returns:
      If this tool has a main class
    • getMainModule

      @Nullable @Nullable String getMainModule()
      The main module to use when executing this tool. Can be null, but does not necessarily mean that the tool is not executable. When set, this will enable the module path when executing this tool. Using ModularitySpec.getInferModulePath()
      Returns:
      The main module, or null if unspecified
    • hasMainModule

      default boolean hasMainModule()

      If this tool has a strictly defined main module. Can be false, but does not necessarily mean that this tools is not executable.

      If this returns true, then ToolExecBase will set the ModularitySpec.getInferModulePath() to true.

      Returns:
      If this tool has a main module defined.