Table of Contents
API Documentation: | JavaExec |
---|
Executes a Java application in a child process.
Similar to Exec
, but starts a JVM with the given classpath and application class.
apply plugin: 'java' task runApp(type: JavaExec) { classpath = sourceSets.main.runtimeClasspath main = 'package.Main' // arguments to pass to the application args 'appArg1' }
The process can be started in debug mode (see JavaExec.getDebug()
) in an ad-hoc manner by supplying the `--debug-jvm` switch when invoking the build.
gradle someJavaExecTask --debug-jvm
Property | Description |
allJvmArgs | The full set of arguments to use to launch the JVM for the process. This includes arguments to define system properties, the minimum/maximum heap size, and the bootstrap classpath. |
args | The arguments passed to the main class to be executed. |
argumentProviders | Argument providers for the application. |
bootstrapClasspath | The bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used when this classpath is empty. |
classpath | The classpath for executing the main class. |
commandLine | The full command line, including the executable plus its arguments. |
debug | Determines whether debugging is enabled for the test process. When enabled — |
enableAssertions | Returns true if assertions are enabled for the process. |
environment | The environment variables to use for the process. Defaults to the environment of this process. |
errorOutput | The output stream to consume standard error from the process executing the command. Default to |
executable | The name of the executable to use. |
ignoreExitValue | Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults to |
jvmArgs | The extra arguments to use to launch the JVM for the process. Does not include system properties and the minimum/maximum heap size. |
jvmArgumentProviders | Command line argument providers for the java process to fork. |
main | The fully qualified name of the Main class to be executed. |
maxHeapSize | The maximum heap size for the process, if any. |
standardInput | The standard input stream for the process executing the command. The stream is closed after the process completes. Defaults to an empty stream. |
standardOutput | The output stream to consume standard output from the process executing the command. Defaults to |
systemProperties | The system properties which will be used for the process. |
workingDir | The working directory for the process. Defaults to the project directory. |
Method | Description |
args(args) | Adds args for the main class to be executed. |
args(args) | Adds args for the main class to be executed. |
bootstrapClasspath(classpath) | Adds the given values to the end of the bootstrap classpath for the process. |
classpath(paths) | Adds elements to the classpath for executing the main class. |
copyTo(options) | Copies these options to the given options. |
copyTo(target) | Copies these options to the given target options. |
environment(name, value) | Adds an environment variable to the environment for this process. |
environment(environmentVariables) | Adds some environment variables to the environment for this process. |
executable(executable) | Sets the name of the executable to use. |
jvmArgs(arguments) | Adds some arguments to use to launch the JVM for the process. |
jvmArgs(arguments) | Adds some arguments to use to launch the JVM for the process. |
systemProperties(properties) | Adds some system properties to use for the process. |
workingDir(dir) | Sets the working directory for the process. The supplied argument is evaluated as per |
The full set of arguments to use to launch the JVM for the process. This includes arguments to define system properties, the minimum/maximum heap size, and the bootstrap classpath.
Argument providers for the application.
- Default:
[]
The bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used when this classpath is empty.
- Default:
[]
The full command line, including the executable plus its arguments.
Determines whether debugging is enabled for the test process. When enabled — debug = true
— the process
is started in a suspended state, listening on port 5005. You should disable parallel test execution when
debugging and you will need to reattach the debugger occasionally if you use a non-zero value for
Test.getForkEvery()
.
- Default:
false
The environment variables to use for the process. Defaults to the environment of this process.
- Default:
- Current process' environment
The output stream to consume standard error from the process executing the command. Default to System.err
.
- Default:
System.err
Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults to false
.
- Default:
false
The extra arguments to use to launch the JVM for the process. Does not include system properties and the minimum/maximum heap size.
- Default:
[]
Command line argument providers for the java process to fork.
- Default:
[]
The standard input stream for the process executing the command. The stream is closed after the process completes. Defaults to an empty stream.
- Default:
- An empty
InputStream
The output stream to consume standard output from the process executing the command. Defaults to System.out
.
- Default:
System.out
The system properties which will be used for the process.
- Default:
[:]
The working directory for the process. Defaults to the project directory.
- Default:
project.projectDir
Adds args for the main class to be executed.
Adds the given values to the end of the bootstrap classpath for the process.
Copies these options to the given options.
JavaExec
copyTo
(ProcessForkOptions
target)
Copies these options to the given target options.
Adds an environment variable to the environment for this process.
Adds some environment variables to the environment for this process.
Adds some arguments to use to launch the JVM for the process.
Adds some system properties to use for the process.
Sets the working directory for the process. The supplied argument is evaluated as per Project.file(java.lang.Object)
.