Class ToolExecBase<P extends EnhancedProblems>

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
net.minecraftforge.gradleutils.shared.ToolExecBase<P>
Type Parameters:
P - The type of enhanced problems, used for common problems reporting with illegal task arguments
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, EnhancedPluginAdditions, EnhancedTask<P>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, org.gradle.api.Named, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.util.Configurable<org.gradle.api.Task>

public abstract class ToolExecBase<P extends EnhancedProblems> extends org.gradle.api.DefaultTask implements EnhancedTask<P>
This tool execution task is a template on top of JavaExec to make executing tools much easier and more consistent between plugins.
See Also:
Implementation Requirements:
Implementing plugins should make a shared subclass named ToolExec which all other tool executing tasks should extend from.
  • Nested Class Summary

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

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

    Fields
    Modifier and Type
    Field
    Description
    protected final org.gradle.api.file.DirectoryProperty
    The default tool directory (usage is not required).

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new task instance using the given types and tool information.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    This method should be overridden by subclasses to add arguments to this task via JavaExec.args(java.lang.Object...).
    protected final void
    args(Iterable<?> args)
     
    protected final void
    args(Object... args)
     
    protected final void
    args(String arg, Iterable<? extends File> files)
    Adds each file to the arguments preceded by the given argument.
    protected final void
    args(String arg, org.gradle.api.file.FileSystemLocationProperty<? extends org.gradle.api.file.FileSystemLocation> fileProvider)
    Adds the given argument followed by the given file location to the arguments.
    protected final void
    args(String arg, @UnknownNullability org.gradle.api.provider.Provider<?> provider)
    Adds the given argument followed by the given object (may be a file location) to the arguments.
    protected final void
    args(Map<?,?> args)
    Adds the given map of arguments.
    protected final void
    environment(String key, String value)
     
    protected org.gradle.process.ExecResult
     
    org.gradle.api.provider.ListProperty<String>
    Additional arguments to use when invoking the tool.
    abstract org.gradle.api.file.ConfigurableFileCollection
     
    protected abstract org.gradle.api.artifacts.dsl.DependencyFactory
     
    protected abstract org.gradle.process.ExecOperations
     
    abstract org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher>
     
    protected abstract org.gradle.jvm.toolchain.JavaToolchainService
     
    protected abstract org.gradle.api.file.RegularFileProperty
     
    org.gradle.api.logging.LoggingManager
    Deprecated.
    abstract org.gradle.api.provider.Property<String>
     
    protected abstract org.gradle.api.model.ObjectFactory
     
    abstract org.gradle.api.provider.Property<Boolean>
     
    protected final P
    The enhanced problems instance to use for this task.
    protected abstract org.gradle.api.provider.ProviderFactory
     
    protected abstract org.gradle.api.provider.Property<org.gradle.api.logging.LogLevel>
     
    protected abstract org.gradle.api.provider.Property<org.gradle.api.logging.LogLevel>
     
    protected abstract org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher>
     
    abstract org.gradle.api.file.DirectoryProperty
     
    protected final void
    jvmArgs(Iterable<?> args)
     
    protected final void
    jvmArgs(Object... args)
     
    protected final void
     
    final void
    using(CharSequence dependency)
     
    final void
    using(org.gradle.api.artifacts.Dependency dependency)
     
    final void
    using(org.gradle.api.provider.Provider<? extends org.gradle.api.artifacts.Dependency> dependency)
     
    final void
    using(org.gradle.api.provider.ProviderConvertible<? extends org.gradle.api.artifacts.Dependency> dependency)
     

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.gradle.api.plugins.ExtensionAware

    getExtensions

    Methods inherited from interface org.gradle.api.Task

    configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, doNotTrackState, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getFinalizedBy, getGroup, getLocalState, getLogger, getMustRunAfter, getName, getPath, getProject, getShouldRunAfter, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, notCompatibleWithConfigurationCache, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
  • Field Details

    • defaultToolDir

      protected final org.gradle.api.file.DirectoryProperty defaultToolDir
      The default tool directory (usage is not required).
  • Constructor Details

    • ToolExecBase

      protected ToolExecBase(Tool tool)
      Creates a new task instance using the given types and tool information.
      Parameters:
      tool - The tool to use for this task
      Implementation Requirements:
      The implementing subclass must make their constructor public, annotated with Inject, and have only a single parameter for Tool, passing in static plugin and problems types to this base constructor. The types must also be manually specified in the class declaration when overriding this class. The best practice is to make a single ToolExec class for the implementing plugin to use, which other tasks can extend off of.
  • Method Details

    • getAdditionalArgs

      @Input @Optional public org.gradle.api.provider.ListProperty<String> getAdditionalArgs()
      Additional arguments to use when invoking the tool. Use in configuration instead of args.
      Returns:
      The list property for the additional arguments
    • getClasspath

      @InputFiles @Classpath public abstract org.gradle.api.file.ConfigurableFileCollection getClasspath()
    • getMainClass

      @Input @Optional public abstract org.gradle.api.provider.Property<String> getMainClass()
    • getJavaLauncher

      public abstract org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher> getJavaLauncher()
    • getToolchainLauncher

      protected abstract org.gradle.api.provider.Property<org.gradle.jvm.toolchain.JavaLauncher> getToolchainLauncher()
    • getPreferToolchainJvm

      @Input @Optional public abstract org.gradle.api.provider.Property<Boolean> getPreferToolchainJvm()
    • getWorkingDir

      @Internal public abstract org.gradle.api.file.DirectoryProperty getWorkingDir()
    • getLogging

      @Deprecated public org.gradle.api.logging.LoggingManager getLogging()
      Deprecated.
      Specified by:
      getLogging in interface org.gradle.api.Task
      Overrides:
      getLogging in class org.gradle.api.DefaultTask
    • getStandardOutputLogLevel

      @Console protected abstract org.gradle.api.provider.Property<org.gradle.api.logging.LogLevel> getStandardOutputLogLevel()
    • getStandardErrorLogLevel

      @Console protected abstract org.gradle.api.provider.Property<org.gradle.api.logging.LogLevel> getStandardErrorLogLevel()
    • getLogFile

      @Internal protected abstract org.gradle.api.file.RegularFileProperty getLogFile()
    • getObjects

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

      @Inject protected abstract org.gradle.api.provider.ProviderFactory getProviders()
    • getExecOperations

      @Inject protected abstract org.gradle.process.ExecOperations getExecOperations()
    • getDependencyFactory

      @Inject protected abstract org.gradle.api.artifacts.dsl.DependencyFactory getDependencyFactory()
    • getJavaToolchains

      @Inject protected abstract org.gradle.jvm.toolchain.JavaToolchainService getJavaToolchains()
    • using

      public final void using(CharSequence dependency)
    • using

      public final void using(org.gradle.api.provider.Provider<? extends org.gradle.api.artifacts.Dependency> dependency)
    • using

      public final void using(org.gradle.api.provider.ProviderConvertible<? extends org.gradle.api.artifacts.Dependency> dependency)
    • using

      public final void using(org.gradle.api.artifacts.Dependency dependency)
    • getProblems

      @Internal protected final P getProblems()
      The enhanced problems instance to use for this task.
      Returns:
      The enhanced problems
    • addArguments

      @MustBeInvokedByOverriders protected void addArguments()
      This method should be overridden by subclasses to add arguments to this task via JavaExec.args(java.lang.Object...). To preserve arguments added by superclasses, this method must be invoked by overriders.
    • exec

      protected org.gradle.process.ExecResult exec() throws IOException
      Throws:
      IOException
      Implementation Note:
      Not invoking this method from an overriding method will result in the tool never being executed and addArguments() never being run.
    • args

      protected final void args(Object... args)
    • args

      protected final void args(Iterable<?> args)
    • args

      protected final void args(String arg, Iterable<? extends File> files)
      Adds each file to the arguments preceded by the given argument. Designed to work well with JOpt Simple.
      Parameters:
      arg - The flag to use for each file
      files - The files to add
    • args

      protected final void args(String arg, org.gradle.api.file.FileSystemLocationProperty<? extends org.gradle.api.file.FileSystemLocation> fileProvider)
      Adds the given argument followed by the given file location to the arguments.
      Parameters:
      arg - The flag to use
      fileProvider - The file to add
    • args

      protected final void args(String arg, @UnknownNullability org.gradle.api.provider.Provider<?> provider)
      Adds the given argument followed by the given object (may be a file location) to the arguments.
      Parameters:
      arg - The flag to use
      provider - The object (or file) to add
    • args

      protected final void args(Map<?,?> args)

      Adds the given map of arguments.

      args(String, Provider) will be invoked for each entry in the map. If the key and/or value are not of the required types, they will be automatically converted using Object.toString() and ProviderFactory.provider(Callable).

      Parameters:
      args - The args to add
    • jvmArgs

      protected final void jvmArgs(Object... args)
    • jvmArgs

      protected final void jvmArgs(Iterable<?> args)
    • environment

      protected final void environment(String key, String value)
    • systemProperty

      protected final void systemProperty(String key, String value)