Klasse Exec

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.AbstractExecTask<Exec>
org.gradle.api.tasks.Exec
Alle implementierten Schnittstellen:
Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Named, ExtensionAware, Task, BaseExecSpec, ExecSpec, ProcessForkOptions, Configurable<Task>

@DisableCachingByDefault(because="Gradle would require more information to cache this task") public abstract class Exec extends AbstractExecTask<Exec>
Executes a command line process. Example:
 task stopTomcat(type:Exec) {
   workingDir '../tomcat/bin'

   //on windows:
   commandLine 'cmd.exe', '/d', '/c', 'stop.bat'

   //on linux
   commandLine './stop.sh'

   //store the output instead of printing to the console:
   standardOutput = new ByteArrayOutputStream()

   //extension method stopTomcat.output() can be used to obtain the output:
   ext.output = {
     return standardOutput.toString()
   }
 }
 
  • Konstruktordetails

    • Exec

      public Exec()
  • Methodendetails

    • getArgs

      @Nullable public List<String> getArgs()
      Returns the arguments for the command to be executed. Defaults to an empty list.
      Angegeben von:
      getArgs in Schnittstelle ExecSpec
      Setzt außer Kraft:
      getArgs in Klasse AbstractExecTask<Exec>
    • setArgs

      public Exec setArgs(List<String> arguments)
      Sets the arguments for the command to be executed.
      Angegeben von:
      setArgs in Schnittstelle ExecSpec
      Setzt außer Kraft:
      setArgs in Klasse AbstractExecTask<Exec>
      Parameter:
      arguments - args for the command
      Gibt zurück:
      this
    • setArgs

      public Exec setArgs(@Nullable Iterable<?> arguments)
      Sets the arguments for the command to be executed.
      Angegeben von:
      setArgs in Schnittstelle ExecSpec
      Setzt außer Kraft:
      setArgs in Klasse AbstractExecTask<Exec>
      Parameter:
      arguments - args for the command
      Gibt zurück:
      this
    • isIgnoreExitValue

      public boolean isIgnoreExitValue()
      Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults to false.
      Angegeben von:
      isIgnoreExitValue in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      isIgnoreExitValue in Klasse AbstractExecTask<Exec>
      Gibt zurück:
      whether a non-zero exit value is ignored, or an exception thrown
    • setIgnoreExitValue

      public Exec setIgnoreExitValue(boolean ignoreExitValue)
      Sets whether a non-zero exit value is ignored, or an exception thrown.
      Angegeben von:
      setIgnoreExitValue in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      setIgnoreExitValue in Klasse AbstractExecTask<Exec>
      Parameter:
      ignoreExitValue - whether a non-zero exit value is ignored, or an exception thrown
      Gibt zurück:
      this
    • getStandardInput

      public InputStream getStandardInput()
      Returns the standard input stream for the process executing the command. The stream is closed after the process completes. Defaults to an empty stream.
      Angegeben von:
      getStandardInput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      getStandardInput in Klasse AbstractExecTask<Exec>
      Gibt zurück:
      The standard input stream.
    • setStandardInput

      public Exec setStandardInput(InputStream inputStream)
      Sets the standard input stream for the process executing the command. The stream is closed after the process completes.
      Angegeben von:
      setStandardInput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      setStandardInput in Klasse AbstractExecTask<Exec>
      Parameter:
      inputStream - The standard input stream for the process. Must not be null.
      Gibt zurück:
      this
    • getStandardOutput

      @Internal public OutputStream getStandardOutput()
      Returns the output stream to consume standard output from the process executing the command. Defaults to System.out.
      Angegeben von:
      getStandardOutput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      getStandardOutput in Klasse AbstractExecTask<Exec>
      Gibt zurück:
      The output stream
    • setStandardOutput

      public Exec setStandardOutput(OutputStream outputStream)
      Sets the output stream to consume standard output from the process executing the command. The stream is closed after the process completes.
      Angegeben von:
      setStandardOutput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      setStandardOutput in Klasse AbstractExecTask<Exec>
      Parameter:
      outputStream - The standard output stream for the process. Must not be null.
      Gibt zurück:
      this
    • getErrorOutput

      public OutputStream getErrorOutput()
      Returns the output stream to consume standard error from the process executing the command. Default to System.err.
      Angegeben von:
      getErrorOutput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      getErrorOutput in Klasse AbstractExecTask<Exec>
      Gibt zurück:
      The error output stream.
    • setErrorOutput

      public Exec setErrorOutput(OutputStream outputStream)
      Sets the output stream to consume standard error from the process executing the command. The stream is closed after the process completes.
      Angegeben von:
      setErrorOutput in Schnittstelle BaseExecSpec
      Setzt außer Kraft:
      setErrorOutput in Klasse AbstractExecTask<Exec>
      Parameter:
      outputStream - The standard output error stream for the process. Must not be null.
      Gibt zurück:
      this