Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.gradle.api.tasks
Class JavaExec

    java.lang.Object
      org.gradle.api.internal.AbstractTask
          org.gradle.api.DefaultTask
              org.gradle.api.internal.ConventionTask
                  org.gradle.api.tasks.JavaExec

All Implemented Interfaces:
  Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Task, BaseExecSpec, JavaExecSpec, JavaForkOptions, ProcessForkOptions, org.gradle.util.Configurable<Task>

    public class JavaExec

extends org.gradle.api.internal.ConventionTask
implements JavaExecSpec

Executes a Java application in a child process.

Field Summary

Fields inherited from interface org.gradle.api.Task
`TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

Constructor Summary
`JavaExec()`

Method Summary
`JavaExecSpec` | `args(Iterable<?> args)` Adds args for the main class to be executed.
`JavaExec` | `args(Object... args)` Adds args for the main class to be executed.
`JavaExec` | `bootstrapClasspath(Object... classpath)` Adds the given values to the end of the bootstrap classpath for the process.
`JavaExec` | `classpath(Object... paths)` Adds elements to the classpath for executing the main class.
`JavaExec` | `copyTo(JavaForkOptions options)` Copies these options to the given options.
`JavaExec` | `copyTo(ProcessForkOptions target)` Copies these options to the given target options.
`JavaExec` | `environment(Map<String,?> environmentVariables)` Adds some environment variables to the environment for this process.
`JavaExec` | `environment(String name, Object value)` Adds an environment variable to the environment for this process.
`JavaExec` | `executable(Object executable)` Sets the name of the executable to use.
`List<String>` | `getAllJvmArgs()` Returns the full set of arguments to use to launch the JVM for the process.
`List<String>` | `getArgs()` Returns the arguments passed to the main class to be executed.
`FileCollection` | `getBootstrapClasspath()` Returns the bootstrap classpath to use for the process.
`FileCollection` | `getClasspath()` Returns the classpath for executing the main class.
`List<String>` | `getCommandLine()` Returns the full command line, including the executable plus its arguments.
`boolean` | `getDebug()` Returns true if debugging is enabled for the process.
`boolean` | `getEnableAssertions()` Returns true if assertions are enabled for the process.
`Map<String,Object>` | `getEnvironment()` The environment variables to use for the process.
`OutputStream` | `getErrorOutput()` Returns the output stream to consume standard error from the process executing the command.
`String` | `getExecutable()` Returns the name of the executable to use.
`List<String>` | `getJvmArgs()` Returns the extra arguments to use to launch the JVM for the process.
`String` | `getMain()` Returns the fully qualified name of the Main class to be executed.
`String` | `getMaxHeapSize()` Returns the maximum heap size for the process, if any.
`InputStream` | `getStandardInput()` Returns the standard input stream for the process executing the command.
`OutputStream` | `getStandardOutput()` Returns the output stream to consume standard output from the process executing the command.
`Map<String,Object>` | `getSystemProperties()` Returns the system properties which will be used for the process.
`File` | `getWorkingDir()` Returns the working directory for the process.
`boolean` | `isIgnoreExitValue()` Tells whether a non-zero exit value is ignored, or an exception thrown.
`JavaExec` | `jvmArgs(Iterable<?> arguments)` Adds some arguments to use to launch the JVM for the process.
`JavaExec` | `jvmArgs(Object... arguments)` Adds some arguments to use to launch the JVM for the process.
`void` | `setAllJvmArgs(Iterable<?> arguments)` Sets the full set of arguments to use to launch the JVM for the process.
`JavaExec` | `setArgs(Iterable<?> applicationArgs)` Sets the args for the main class to be executed.
`void` | `setBootstrapClasspath(FileCollection classpath)` Sets the bootstrap classpath to use for the process.
`JavaExec` | `setClasspath(FileCollection classpath)` Sets the classpath for executing the main class.
`void` | `setDebug(boolean enabled)` Enable or disable debugging for the process.
`void` | `setEnableAssertions(boolean enabled)` Enable or disable assertions for the process.
`void` | `setEnvironment(Map<String,?> environmentVariables)` Sets the environment variable to use for the process.
`JavaExec` | `setErrorOutput(OutputStream outputStream)` Sets the output stream to consume standard error from the process executing the command.
`void` | `setExecutable(Object executable)` Sets the name of the executable to use.
`JavaExecSpec` | `setIgnoreExitValue(boolean ignoreExitValue)` Sets whether a non-zero exit value is ignored, or an exception thrown.
`void` | `setJvmArgs(Iterable<?> arguments)` Sets the extra arguments to use to launch the JVM for the process.
`JavaExec` | `setMain(String mainClassName)` Sets the fully qualified name of the main class to be executed.
`void` | `setMaxHeapSize(String heapSize)` Sets the maximum heap size for the process.
`JavaExec` | `setStandardInput(InputStream inputStream)` Sets the standard input stream for the process executing the command.
`JavaExec` | `setStandardOutput(OutputStream outputStream)` Sets the output stream to consume standard output from the process executing the command.
`void` | `setSystemProperties(Map<String,?> properties)` Sets the system properties to use for the process.
`void` | `setWorkingDir(Object dir)` Sets the working directory for the process.
`JavaExec` | `systemProperties(Map<String,?> properties)` Adds some system properties to use for the process.
`JavaExec` | `systemProperty(String name, Object value)` Adds a system property to use for the process.
`JavaExec` | `workingDir(Object dir)` Sets the working directory for the process.

Methods inherited from class org.gradle.api.internal.ConventionTask
`conventionMapping, getConventionMapping, setConventionMapping`

Methods inherited from class org.gradle.api.internal.AbstractTask
`addValidator, captureStandardOutput, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, disableStandardOutputCapture, doFirst, doFirst, doLast, doLast, execute, getActions, getAdditionalProperties, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getDynamicObjectHelper, getEnabled, getExecuter, getGroup, getInputs, getLogger, getLogging, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getStandardOutputCapture, getState, getTaskDependencies, getTemporaryDir, getValidators, hasProperty, injectIntoNewInstance, isEnabled, leftShift, onlyIf, onlyIf, property, setActions, setConvention, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setGroup, setName, setOnlyIf, setOnlyIf, setProject, setProperty, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JavaExec

    public JavaExec()

Method Detail

### getAllJvmArgs

    public List<String> getAllJvmArgs()

  Returns the full set of arguments to use to launch the JVM for the process. This includes arguments to define system properties, the maximum heap size, and the bootstrap classpath.

  Specified by:
    `getAllJvmArgs` in interface `JavaForkOptions`
  Returns:
    The arguments. Returns an empty list if there are no arguments.

### setAllJvmArgs

    public void setAllJvmArgs(Iterable<?> arguments)

  Sets the full set of arguments to use to launch the JVM for the process. Overwrites any previously set system properties, maximum heap size, assertions, and bootstrap classpath.

  Specified by:
    `setAllJvmArgs` in interface `JavaForkOptions`
  Parameters:
    `arguments` - The arguments. Must not be null.

### getJvmArgs

    public List<String> getJvmArgs()

  Returns the extra arguments to use to launch the JVM for the process. Does not include system properties and the maximum heap size.

  Specified by:
    `getJvmArgs` in interface `JavaForkOptions`
  Returns:
    The arguments. Returns an empty list if there are no arguments.

### setJvmArgs

    public void setJvmArgs(Iterable<?> arguments)

  Sets the extra arguments to use to launch the JVM for the process. System properties and maximum heap size are updated.

  Specified by:
    `setJvmArgs` in interface `JavaForkOptions`
  Parameters:
    `arguments` - The arguments. Must not be null.

### jvmArgs

    public JavaExec jvmArgs(Iterable<?> arguments)

  Adds some arguments to use to launch the JVM for the process.

  Specified by:
    `jvmArgs` in interface `JavaForkOptions`
  Parameters:
    `arguments` - The arguments. Must not be null.
  Returns:
    this

### jvmArgs

    public JavaExec jvmArgs(Object... arguments)

  Adds some arguments to use to launch the JVM for the process.

  Specified by:
    `jvmArgs` in interface `JavaForkOptions`
  Parameters:
    `arguments` - The arguments.
  Returns:
    this

### getSystemProperties

    public Map<String,Object> getSystemProperties()

  Returns the system properties which will be used for the process.

  Specified by:
    `getSystemProperties` in interface `JavaForkOptions`
  Returns:
    The system properties. Returns an empty map when there are no system properties.

### setSystemProperties

    public void setSystemProperties(Map<String,?> properties)

  Sets the system properties to use for the process.

  Specified by:
    `setSystemProperties` in interface `JavaForkOptions`
  Parameters:
    `properties` - The system properties. Must not be null.

### systemProperties

    public JavaExec systemProperties(Map<String,?> properties)

  Adds some system properties to use for the process.

  Specified by:
    `systemProperties` in interface `JavaForkOptions`
  Parameters:
    `properties` - The system properties. Must not be null.
  Returns:
    this

### systemProperty

    public JavaExec systemProperty(String name,
                                   Object value)

  Adds a system property to use for the process.

  Specified by:
    `systemProperty` in interface `JavaForkOptions`
  Parameters:
    `name` - The name of the property
    `value` - The value for the property. May be null.
  Returns:
    this

### getBootstrapClasspath

    public FileCollection getBootstrapClasspath()

  Returns the bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used when this classpath is empty.

  Specified by:
    `getBootstrapClasspath` in interface `JavaForkOptions`
  Returns:
    The bootstrap classpath. Never returns null.

### setBootstrapClasspath

    public void setBootstrapClasspath(FileCollection classpath)

  Sets the bootstrap classpath to use for the process. Set to an empty classpath to use the default bootstrap classpath for the specified JVM.

  Specified by:
    `setBootstrapClasspath` in interface `JavaForkOptions`
  Parameters:
    `classpath` - The classpath. Must not be null. Can be empty.

### bootstrapClasspath

    public JavaExec bootstrapClasspath(Object... classpath)

  Adds the given values to the end of the bootstrap classpath for the process.

  Specified by:
    `bootstrapClasspath` in interface `JavaForkOptions`
  Parameters:
    `classpath` - The classpath.
  Returns:
    this

### getMaxHeapSize

    public String getMaxHeapSize()

  Returns the maximum heap size for the process, if any.

  Specified by:
    `getMaxHeapSize` in interface `JavaForkOptions`
  Returns:
    The maximum heap size. Returns null if the default maximum heap size should be used.

### setMaxHeapSize

    public void setMaxHeapSize(String heapSize)

  Sets the maximum heap size for the process.

  Specified by:
    `setMaxHeapSize` in interface `JavaForkOptions`
  Parameters:
    `heapSize` - The heap size. Use null for the default maximum heap size.

### getEnableAssertions

    public boolean getEnableAssertions()

  Returns true if assertions are enabled for the process.

  Specified by:
    `getEnableAssertions` in interface `JavaForkOptions`
  Returns:
    true if assertions are enabled, false if disabled

### setEnableAssertions

    public void setEnableAssertions(boolean enabled)

  Enable or disable assertions for the process.

  Specified by:
    `setEnableAssertions` in interface `JavaForkOptions`
  Parameters:
    `enabled` - true to enable assertions, false to disable.

### getDebug

    public boolean getDebug()

  Returns true if debugging is enabled for the process. When enabled, the process is started suspended and listening on port 5005.

  Specified by:
    `getDebug` in interface `JavaForkOptions`
  Returns:
    true when debugging is enabled, false to disable.

### setDebug

    public void setDebug(boolean enabled)

  Enable or disable debugging for the process. When enabled, the process is started suspended and listening on port 5005.

  Specified by:
    `setDebug` in interface `JavaForkOptions`
  Parameters:
    `enabled` - true to enable debugging, false to disable.

### getMain

    public String getMain()

  Returns the fully qualified name of the Main class to be executed.

  Specified by:
    `getMain` in interface `JavaExecSpec`

### setMain

    public JavaExec setMain(String mainClassName)

  Sets the fully qualified name of the main class to be executed.

  Specified by:
    `setMain` in interface `JavaExecSpec`
  Parameters:
    `mainClassName` - the fully qualified name of the main class to be executed.
  Returns:
    this

### getArgs

    public List<String> getArgs()

  Returns the arguments passed to the main class to be executed.

  Specified by:
    `getArgs` in interface `JavaExecSpec`

### setArgs

    public JavaExec setArgs(Iterable<?> applicationArgs)

  Sets the args for the main class to be executed.

  Specified by:
    `setArgs` in interface `JavaExecSpec`
  Parameters:
    `applicationArgs` - Args for the main class.
  Returns:
    this

### args

    public JavaExec args(Object... args)

  Adds args for the main class to be executed.

  Specified by:
    `args` in interface `JavaExecSpec`
  Parameters:
    `args` - Args for the main class.
  Returns:
    this

### args

    public JavaExecSpec args(Iterable<?> args)

  Adds args for the main class to be executed.

  Specified by:
    `args` in interface `JavaExecSpec`
  Parameters:
    `args` - Args for the main class.
  Returns:
    this

### setClasspath

    public JavaExec setClasspath(FileCollection classpath)

  Sets the classpath for executing the main class.

  Specified by:
    `setClasspath` in interface `JavaExecSpec`
  Parameters:
    `classpath` - the classpath
  Returns:
    this

### classpath

    public JavaExec classpath(Object... paths)

  Adds elements to the classpath for executing the main class.

  Specified by:
    `classpath` in interface `JavaExecSpec`
  Parameters:
    `paths` - classpath elements
  Returns:
    this

### getClasspath

    public FileCollection getClasspath()

  Returns the classpath for executing the main class.

  Specified by:
    `getClasspath` in interface `JavaExecSpec`

### copyTo

    public JavaExec copyTo(JavaForkOptions options)

  Copies these options to the given options.

  Specified by:
    `copyTo` in interface `JavaForkOptions`
  Parameters:
    `options` - The target options.
  Returns:
    this

### getExecutable

    public String getExecutable()

  Returns the name of the executable to use.

  Specified by:
    `getExecutable` in interface `ProcessForkOptions`
  Returns:
    The executable.

### setExecutable

    public void setExecutable(Object executable)

  Sets the name of the executable to use.

  Specified by:
    `setExecutable` in interface `ProcessForkOptions`
  Parameters:
    `executable` - The executable. Must not be null.

### executable

    public JavaExec executable(Object executable)

  Sets the name of the executable to use.

  Specified by:
    `executable` in interface `ProcessForkOptions`
  Parameters:
    `executable` - The executable. Must not be null.
  Returns:
    this

### getWorkingDir

    public File getWorkingDir()

  Returns the working directory for the process. Defaults to the project directory.

  Specified by:
    `getWorkingDir` in interface `ProcessForkOptions`
  Returns:
    The working directory. Never returns null.

### setWorkingDir

    public void setWorkingDir(Object dir)

  Sets the working directory for the process. The supplied argument is evaluated as for `Project.file(Object)`.

  Specified by:
    `setWorkingDir` in interface `ProcessForkOptions`
  Parameters:
    `dir` - The working directory. Must not be null.

### workingDir

    public JavaExec workingDir(Object dir)

  Sets the working directory for the process. The supplied argument is evaluated as for `Project.file(Object)`.

  Specified by:
    `workingDir` in interface `ProcessForkOptions`
  Parameters:
    `dir` - The working directory. Must not be null.
  Returns:
    this

### getEnvironment

    public Map<String,Object> getEnvironment()

  The environment variables to use for the process. Defaults to the environment of this process.

  Specified by:
    `getEnvironment` in interface `ProcessForkOptions`
  Returns:
    The environment. Returns an empty map when there are no environment variables.

### setEnvironment

    public void setEnvironment(Map<String,?> environmentVariables)

  Sets the environment variable to use for the process.

  Specified by:
    `setEnvironment` in interface `ProcessForkOptions`
  Parameters:
    `environmentVariables` - The environment variables. Must not be null.

### environment

    public JavaExec environment(String name,
                                Object value)

  Adds an environment variable to the environment for this process.

  Specified by:
    `environment` in interface `ProcessForkOptions`
  Parameters:
    `name` - The name of the variable.
    `value` - The value for the variable. Must not be null.
  Returns:
    this

### environment

    public JavaExec environment(Map<String,?> environmentVariables)

  Adds some environment variables to the environment for this process.

  Specified by:
    `environment` in interface `ProcessForkOptions`
  Parameters:
    `environmentVariables` - The environment variables. Must not be null.
  Returns:
    this

### copyTo

    public JavaExec copyTo(ProcessForkOptions target)

  Copies these options to the given target options.

  Specified by:
    `copyTo` in interface `ProcessForkOptions`
  Parameters:
    `target` - The target options
  Returns:
    this

### setStandardInput

    public JavaExec setStandardInput(InputStream inputStream)

  Sets the standard input stream for the process executing the command. The stream is closed after the process completes.

  Specified by:
    `setStandardInput` in interface `BaseExecSpec`
  Parameters:
    `inputStream` - The standard input stream for the process. Must not be null.
  Returns:
    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.

  Specified by:
    `getStandardInput` in interface `BaseExecSpec`
  Returns:
    The standard input stream.

### setStandardOutput

    public JavaExec 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.

  Specified by:
    `setStandardOutput` in interface `BaseExecSpec`
  Parameters:
    `outputStream` - The standard output stream for the process. Must not be null.
  Returns:
    this

### getStandardOutput

    public OutputStream getStandardOutput()

  Returns the output stream to consume standard output from the process executing the command. Defaults to `System.out`.

  Specified by:
    `getStandardOutput` in interface `BaseExecSpec`
  Returns:
    The output stream

### setErrorOutput

    public JavaExec 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.

  Specified by:
    `setErrorOutput` in interface `BaseExecSpec`
  Parameters:
    `outputStream` - The standard output error stream for the process. Must not be null.
  Returns:
    this

### getErrorOutput

    public OutputStream getErrorOutput()

  Returns the output stream to consume standard error from the process executing the command. Default to `System.err`.

  Specified by:
    `getErrorOutput` in interface `BaseExecSpec`
  Returns:
    The error output stream.

### setIgnoreExitValue

    public JavaExecSpec setIgnoreExitValue(boolean ignoreExitValue)

  Sets whether a non-zero exit value is ignored, or an exception thrown.

  Specified by:
    `setIgnoreExitValue` in interface `BaseExecSpec`
  Parameters:
    `ignoreExitValue` - whether a non-zero exit value is ignored, or an exception thrown
  Returns:
    this

### isIgnoreExitValue

    public boolean isIgnoreExitValue()

  Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults to `false`.

  Specified by:
    `isIgnoreExitValue` in interface `BaseExecSpec`
  Returns:
    whether a non-zero exit value is ignored, or an exception thrown

### getCommandLine

    public List<String> getCommandLine()

  Returns the full command line, including the executable plus its arguments.

  Specified by:
    `getCommandLine` in interface `BaseExecSpec`
  Returns:
    The full command line, including the executable plus its arguments

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD