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:
java.lang.Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.IConventionAware
,org.gradle.api.internal.TaskInternal
,Named
,ExtensionAware
,Task
,BaseExecSpec
,JavaExecSpec
,JavaForkOptions
,ProcessForkOptions
,Configurable<Task>
@DisableCachingByDefault(because="Gradle would require more information to cache this task") public abstract class JavaExec extends org.gradle.api.internal.ConventionTask implements JavaExecSpec
Executes a Java application in a child process.Similar to
Exec
, but starts a JVM with the given classpath and application class.plugins { id 'java' } task runApp(type: JavaExec) { classpath = sourceSets.main.runtimeClasspath mainClass = 'package.Main' // arguments to pass to the application args 'appArg1' } // Using and creating an Executable Jar jar { manifest { attributes('Main-Class': 'package.Main') } } task runExecutableJar(type: JavaExec) { // Executable jars can have only _one_ jar on the classpath. classpath = files(tasks.jar) // 'main' does not need to be specified // arguments to pass to the application args 'appArg1' }
The process can be started in debug mode (see
getDebug()
) in an ad-hoc manner by supplying the `--debug-jvm` switch when invoking the build.gradle someJavaExecTask --debug-jvm
Also, debug configuration can be explicitly set in
debugOptions(Action)
:task runApp(type: JavaExec) { ... debugOptions { enabled = true port = 5566 server = true suspend = false } }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
-
Field Summary
-
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 Constructor Description JavaExec()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JavaExecSpec
args(java.lang.Iterable<?> args)
Adds args for the main class to be executed.JavaExec
args(java.lang.Object... args)
Adds args for the main class to be executed.JavaExec
bootstrapClasspath(java.lang.Object... classpath)
Adds the given values to the end of the bootstrap classpath for the process.JavaExec
classpath(java.lang.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.void
debugOptions(Action<JavaDebugOptions> action)
Configures Java Debug Wire Protocol properties for the process.JavaExec
environment(java.lang.String name, java.lang.Object value)
Adds an environment variable to the environment for this process.JavaExec
environment(java.util.Map<java.lang.String,?> environmentVariables)
Adds some environment variables to the environment for this process.void
exec()
JavaExec
executable(java.lang.Object executable)
Sets the name of the executable to use.java.util.List<java.lang.String>
getAllJvmArgs()
Returns the full set of arguments to use to launch the JVM for the process.java.util.List<java.lang.String>
getArgs()
Returns the arguments passed to the main class to be executed.java.util.List<CommandLineArgumentProvider>
getArgumentProviders()
Argument providers for the application.FileCollection
getBootstrapClasspath()
Returns the bootstrap classpath to use for the process.FileCollection
getClasspath()
Returns the classpath for executing the main class.java.util.List<java.lang.String>
getCommandLine()
Returns the full command line, including the executable plus its arguments.boolean
getDebug()
Determines whether debugging is enabled for the test process.JavaDebugOptions
getDebugOptions()
Returns the Java Debug Wire Protocol properties for the process.java.lang.String
getDefaultCharacterEncoding()
Returns the default character encoding to use.boolean
getEnableAssertions()
Returns true if assertions are enabled for the process.java.util.Map<java.lang.String,java.lang.Object>
getEnvironment()
The environment variables to use for the process.java.io.OutputStream
getErrorOutput()
Returns the output stream to consume standard error from the process executing the command.protected org.gradle.process.internal.ExecActionFactory
getExecActionFactory()
java.lang.String
getExecutable()
Returns the name of the executable to use.Provider<ExecResult>
getExecutionResult()
Returns the result for the command run by this task.Property<JavaLauncher>
getJavaLauncher()
Configures the java executable to be used to run the tests.protected JavaToolchainService
getJavaToolchainService()
JavaVersion
getJavaVersion()
Returns the version of the Java executable specified bygetJavaLauncher()
.java.util.List<java.lang.String>
getJvmArgs()
Returns the extra arguments to use to launch the JVM for the process.java.util.List<CommandLineArgumentProvider>
getJvmArgumentProviders()
Command line argument providers for the java process to fork.ListProperty<java.lang.String>
getJvmArguments()
Extra JVM arguments to be to use to launch the JVM for the process.Property<java.lang.String>
getMainClass()
The fully qualified name of the Main class to be executed.Property<java.lang.String>
getMainModule()
The name of the main module to be executed if the application should run as a Java module.java.lang.String
getMaxHeapSize()
Returns the maximum heap size for the process, if any.java.lang.String
getMinHeapSize()
Returns the minimum heap size for the process, if any.ModularitySpec
getModularity()
Returns the module path handling for executing the main class.protected ObjectFactory
getObjectFactory()
protected ProviderFactory
getProviderFactory()
java.io.InputStream
getStandardInput()
Returns the standard input stream for the process executing the command.java.io.OutputStream
getStandardOutput()
Returns the output stream to consume standard output from the process executing the command.java.util.Map<java.lang.String,java.lang.Object>
getSystemProperties()
Returns the system properties which will be used for the process.java.io.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(java.lang.Iterable<?> arguments)
Adds some arguments to use to launch the JVM for the process.JavaExec
jvmArgs(java.lang.Object... arguments)
Adds some arguments to use to launch the JVM for the process.void
setAllJvmArgs(java.lang.Iterable<?> arguments)
Sets the full set of arguments to use to launch the JVM for the process.void
setAllJvmArgs(java.util.List<java.lang.String> arguments)
Sets the full set of arguments to use to launch the JVM for the process.JavaExec
setArgs(java.lang.Iterable<?> applicationArgs)
Sets the args for the main class to be executed.JavaExec
setArgs(java.util.List<java.lang.String> applicationArgs)
Sets the args for the main class to be executed.JavaExec
setArgsString(java.lang.String args)
Parses an argument list fromargs
and passes it tosetArgs(List)
.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
setDefaultCharacterEncoding(java.lang.String defaultCharacterEncoding)
Sets the default character encoding to use.void
setEnableAssertions(boolean enabled)
Enable or disable assertions for the process.void
setEnvironment(java.util.Map<java.lang.String,?> environmentVariables)
Sets the environment variable to use for the process.JavaExec
setErrorOutput(java.io.OutputStream outputStream)
Sets the output stream to consume standard error from the process executing the command.void
setExecutable(java.lang.Object executable)
Sets the name of the executable to use.void
setExecutable(java.lang.String 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(java.lang.Iterable<?> arguments)
Sets the extra arguments to use to launch the JVM for the process.void
setJvmArgs(java.util.List<java.lang.String> arguments)
Sets the extra arguments to use to launch the JVM for the process.void
setMaxHeapSize(java.lang.String heapSize)
Sets the maximum heap size for the process.void
setMinHeapSize(java.lang.String heapSize)
Sets the minimum heap size for the process.JavaExec
setStandardInput(java.io.InputStream inputStream)
Sets the standard input stream for the process executing the command.JavaExec
setStandardOutput(java.io.OutputStream outputStream)
Sets the output stream to consume standard output from the process executing the command.void
setSystemProperties(java.util.Map<java.lang.String,?> properties)
Sets the system properties to use for the process.void
setWorkingDir(java.io.File dir)
Sets the working directory for the process.void
setWorkingDir(java.lang.Object dir)
Sets the working directory for the process.JavaExec
systemProperties(java.util.Map<java.lang.String,?> properties)
Adds some system properties to use for the process.JavaExec
systemProperty(java.lang.String name, java.lang.Object value)
Adds a system property to use for the process.JavaExec
workingDir(java.lang.Object dir)
Sets the working directory for the process.-
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
-
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, getLogging, 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, getConvention, 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 org.gradle.process.JavaExecSpec
setMain
-
Methods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-
-
-
Method Detail
-
exec
public void exec()
-
getAllJvmArgs
public java.util.List<java.lang.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 minimum/maximum heap size, and the bootstrap classpath.- Specified by:
getAllJvmArgs
in interfaceJavaForkOptions
- Returns:
- The immutable list of arguments. Returns an empty list if there are no arguments.
-
setAllJvmArgs
public void setAllJvmArgs(java.util.List<java.lang.String> arguments)
Sets the full set of arguments to use to launch the JVM for the process. Overwrites any previously set system properties, minimum/maximum heap size, assertions, and bootstrap classpath.- Specified by:
setAllJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
setAllJvmArgs
public void setAllJvmArgs(java.lang.Iterable<?> arguments)
Sets the full set of arguments to use to launch the JVM for the process. Overwrites any previously set system properties, minimum/maximum heap size, assertions, and bootstrap classpath.- Specified by:
setAllJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
getJvmArgs
public java.util.List<java.lang.String> getJvmArgs()
Returns the extra arguments to use to launch the JVM for the process. Does not include system properties and the minimum/maximum heap size.- Specified by:
getJvmArgs
in interfaceJavaForkOptions
- Returns:
- The immutable list of arguments. Returns an empty list if there are no arguments.
-
setJvmArgs
public void setJvmArgs(java.util.List<java.lang.String> arguments)
Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.- Specified by:
setJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
setJvmArgs
public void setJvmArgs(java.lang.Iterable<?> arguments)
Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.- Specified by:
setJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
jvmArgs
public JavaExec jvmArgs(java.lang.Iterable<?> arguments)
Adds some arguments to use to launch the JVM for the process.- Specified by:
jvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.- Returns:
- this
-
jvmArgs
public JavaExec jvmArgs(java.lang.Object... arguments)
Adds some arguments to use to launch the JVM for the process.- Specified by:
jvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments.- Returns:
- this
-
getSystemProperties
public java.util.Map<java.lang.String,java.lang.Object> getSystemProperties()
Returns the system properties which will be used for the process.- Specified by:
getSystemProperties
in interfaceJavaForkOptions
- Returns:
- The system properties. Returns an empty map when there are no system properties.
-
setSystemProperties
public void setSystemProperties(java.util.Map<java.lang.String,?> properties)
Sets the system properties to use for the process.- Specified by:
setSystemProperties
in interfaceJavaForkOptions
- Parameters:
properties
- The system properties. Must not be null.
-
systemProperties
public JavaExec systemProperties(java.util.Map<java.lang.String,?> properties)
Adds some system properties to use for the process.- Specified by:
systemProperties
in interfaceJavaForkOptions
- Parameters:
properties
- The system properties. Must not be null.- Returns:
- this
-
systemProperty
public JavaExec systemProperty(java.lang.String name, java.lang.Object value)
Adds a system property to use for the process.- Specified by:
systemProperty
in interfaceJavaForkOptions
- Parameters:
name
- The name of the propertyvalue
- 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 interfaceJavaForkOptions
- 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 interfaceJavaForkOptions
- Parameters:
classpath
- The classpath. Must not be null. Can be empty.
-
bootstrapClasspath
public JavaExec bootstrapClasspath(java.lang.Object... classpath)
Adds the given values to the end of the bootstrap classpath for the process.- Specified by:
bootstrapClasspath
in interfaceJavaForkOptions
- Parameters:
classpath
- The classpath.- Returns:
- this
-
getMinHeapSize
public java.lang.String getMinHeapSize()
Returns the minimum heap size for the process, if any.- Specified by:
getMinHeapSize
in interfaceJavaForkOptions
- Returns:
- The minimum heap size. Returns null if the default minimum heap size should be used.
-
setMinHeapSize
public void setMinHeapSize(java.lang.String heapSize)
Sets the minimum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").- Specified by:
setMinHeapSize
in interfaceJavaForkOptions
- Parameters:
heapSize
- The minimum heap size. Use null for the default minimum heap size.
-
getDefaultCharacterEncoding
public java.lang.String getDefaultCharacterEncoding()
Returns the default character encoding to use.- Specified by:
getDefaultCharacterEncoding
in interfaceJavaForkOptions
- Returns:
- The default character encoding. Returns null if the
default character encoding of this JVM
should be used.
-
setDefaultCharacterEncoding
public void setDefaultCharacterEncoding(java.lang.String defaultCharacterEncoding)
Sets the default character encoding to use. Note: Many JVM implementations support the setting of this attribute via system property on startup (namely, thefile.encoding
property). For JVMs where this is the case, setting thefile.encoding
property viaJavaForkOptions.setSystemProperties(java.util.Map)
or similar will have no effect as this value will be overridden by the value specified byJavaForkOptions.getDefaultCharacterEncoding()
.- Specified by:
setDefaultCharacterEncoding
in interfaceJavaForkOptions
- Parameters:
defaultCharacterEncoding
- The default character encoding. Use null to usethis JVM's default charset
-
getMaxHeapSize
public java.lang.String getMaxHeapSize()
Returns the maximum heap size for the process, if any.- Specified by:
getMaxHeapSize
in interfaceJavaForkOptions
- Returns:
- The maximum heap size. Returns null if the default maximum heap size should be used.
-
setMaxHeapSize
public void setMaxHeapSize(java.lang.String heapSize)
Sets the maximum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").- Specified by:
setMaxHeapSize
in interfaceJavaForkOptions
- 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 interfaceJavaForkOptions
- 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 interfaceJavaForkOptions
- Parameters:
enabled
- true to enable assertions, false to disable.
-
getDebug
public boolean getDebug()
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 forTest.getForkEvery()
.Since Gradle 5.6, you can configure the port and other Java debug properties via
JavaForkOptions.debugOptions(Action)
.- Specified by:
getDebug
in interfaceJavaForkOptions
- 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.The debug properties (e.g. the port number) can be configured in
JavaForkOptions.debugOptions(Action)
.- Specified by:
setDebug
in interfaceJavaForkOptions
- Parameters:
enabled
- true to enable debugging, false to disable.
-
getDebugOptions
public JavaDebugOptions getDebugOptions()
Returns the Java Debug Wire Protocol properties for the process. If enabled then the-agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.- Specified by:
getDebugOptions
in interfaceJavaForkOptions
-
debugOptions
public void debugOptions(Action<JavaDebugOptions> action)
Configures Java Debug Wire Protocol properties for the process. IfJavaForkOptions.setDebug(boolean)
is enabled then the-agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.- Specified by:
debugOptions
in interfaceJavaForkOptions
- Parameters:
action
- the Java debug configuration
-
getMainModule
public Property<java.lang.String> getMainModule()
The name of the main module to be executed if the application should run as a Java module.- Specified by:
getMainModule
in interfaceJavaExecSpec
-
getMainClass
public Property<java.lang.String> getMainClass()
The fully qualified name of the Main class to be executed.This does not need to be set if using an Executable Jar with a
Main-Class
attribute.- Specified by:
getMainClass
in interfaceJavaExecSpec
-
getArgs
public java.util.List<java.lang.String> getArgs()
Returns the arguments passed to the main class to be executed.- Specified by:
getArgs
in interfaceJavaExecSpec
-
setArgsString
public JavaExec setArgsString(java.lang.String args)
Parses an argument list fromargs
and passes it tosetArgs(List)
.The parser supports both single quote (
'
) and double quote ("
) as quote delimiters. For example, to pass the argumentfoo bar
, use"foo bar"
.Note: the parser does not support using backslash to escape quotes. If this is needed, use the other quote delimiter around it. For example, to pass the argument
'singly quoted'
, use"'singly quoted'"
.- Parameters:
args
- Args for the main class. Will be parsed into an argument list.- Returns:
- this
- Since:
- 4.9
-
setArgs
public JavaExec setArgs(java.util.List<java.lang.String> applicationArgs)
Sets the args for the main class to be executed.- Specified by:
setArgs
in interfaceJavaExecSpec
- Parameters:
applicationArgs
- Args for the main class.- Returns:
- this
-
setArgs
public JavaExec setArgs(java.lang.Iterable<?> applicationArgs)
Sets the args for the main class to be executed.- Specified by:
setArgs
in interfaceJavaExecSpec
- Parameters:
applicationArgs
- Args for the main class.- Returns:
- this
-
args
public JavaExec args(java.lang.Object... args)
Adds args for the main class to be executed.- Specified by:
args
in interfaceJavaExecSpec
- Parameters:
args
- Args for the main class.- Returns:
- this
-
args
public JavaExecSpec args(java.lang.Iterable<?> args)
Adds args for the main class to be executed.- Specified by:
args
in interfaceJavaExecSpec
- Parameters:
args
- Args for the main class.- Returns:
- this
-
getArgumentProviders
public java.util.List<CommandLineArgumentProvider> getArgumentProviders()
Argument providers for the application.- Specified by:
getArgumentProviders
in interfaceJavaExecSpec
-
setClasspath
public JavaExec setClasspath(FileCollection classpath)
Sets the classpath for executing the main class.- Specified by:
setClasspath
in interfaceJavaExecSpec
- Parameters:
classpath
- the classpath- Returns:
- this
-
classpath
public JavaExec classpath(java.lang.Object... paths)
Adds elements to the classpath for executing the main class.- Specified by:
classpath
in interfaceJavaExecSpec
- Parameters:
paths
- classpath elements- Returns:
- this
-
getClasspath
public FileCollection getClasspath()
Returns the classpath for executing the main class.- Specified by:
getClasspath
in interfaceJavaExecSpec
-
getModularity
public ModularitySpec getModularity()
Returns the module path handling for executing the main class.- Specified by:
getModularity
in interfaceJavaExecSpec
-
copyTo
public JavaExec copyTo(JavaForkOptions options)
Copies these options to the given options.- Specified by:
copyTo
in interfaceJavaForkOptions
- Parameters:
options
- The target options.- Returns:
- this
-
getJavaVersion
@Input public JavaVersion getJavaVersion()
Returns the version of the Java executable specified bygetJavaLauncher()
.- Since:
- 5.2
-
getExecutable
@Internal("covered by getJavaVersion") @Nullable public java.lang.String getExecutable()
Returns the name of the executable to use.- Specified by:
getExecutable
in interfaceProcessForkOptions
- Returns:
- The executable.
-
setExecutable
public void setExecutable(java.lang.String executable)
Sets the name of the executable to use.- Specified by:
setExecutable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.
-
setExecutable
public void setExecutable(java.lang.Object executable)
Sets the name of the executable to use.- Specified by:
setExecutable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.
-
executable
public JavaExec executable(java.lang.Object executable)
Sets the name of the executable to use.- Specified by:
executable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.- Returns:
- this
-
getWorkingDir
@Internal public java.io.File getWorkingDir()
Returns the working directory for the process. Defaults to the project directory.- Specified by:
getWorkingDir
in interfaceProcessForkOptions
- Returns:
- The working directory. Never returns null.
-
setWorkingDir
public void setWorkingDir(java.io.File dir)
Sets the working directory for the process.- Specified by:
setWorkingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.
-
setWorkingDir
public void setWorkingDir(java.lang.Object dir)
Sets the working directory for the process. The supplied argument is evaluated as perProject.file(Object)
.- Specified by:
setWorkingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.
-
workingDir
public JavaExec workingDir(java.lang.Object dir)
Sets the working directory for the process. The supplied argument is evaluated as perProject.file(Object)
.- Specified by:
workingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.- Returns:
- this
-
getEnvironment
@Internal public java.util.Map<java.lang.String,java.lang.Object> getEnvironment()
The environment variables to use for the process. Defaults to the environment of this process.- Specified by:
getEnvironment
in interfaceProcessForkOptions
- Returns:
- The environment. Returns an empty map when there are no environment variables.
-
setEnvironment
public void setEnvironment(java.util.Map<java.lang.String,?> environmentVariables)
Sets the environment variable to use for the process.- Specified by:
setEnvironment
in interfaceProcessForkOptions
- Parameters:
environmentVariables
- The environment variables. Must not be null.
-
environment
public JavaExec environment(java.lang.String name, java.lang.Object value)
Adds an environment variable to the environment for this process.- Specified by:
environment
in interfaceProcessForkOptions
- Parameters:
name
- The name of the variable.value
- The value for the variable. Must not be null.- Returns:
- this
-
environment
public JavaExec environment(java.util.Map<java.lang.String,?> environmentVariables)
Adds some environment variables to the environment for this process.- Specified by:
environment
in interfaceProcessForkOptions
- 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 interfaceProcessForkOptions
- Parameters:
target
- The target options- Returns:
- this
-
setStandardInput
public JavaExec setStandardInput(java.io.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 interfaceBaseExecSpec
- Parameters:
inputStream
- The standard input stream for the process. Must not be null.- Returns:
- this
-
getStandardInput
@Internal public java.io.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 interfaceBaseExecSpec
- Returns:
- The standard input stream.
-
setStandardOutput
public JavaExec setStandardOutput(java.io.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 interfaceBaseExecSpec
- Parameters:
outputStream
- The standard output stream for the process. Must not be null.- Returns:
- this
-
getStandardOutput
@Internal public java.io.OutputStream getStandardOutput()
Returns the output stream to consume standard output from the process executing the command. Defaults toSystem.out
.- Specified by:
getStandardOutput
in interfaceBaseExecSpec
- Returns:
- The output stream
-
setErrorOutput
public JavaExec setErrorOutput(java.io.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 interfaceBaseExecSpec
- Parameters:
outputStream
- The standard output error stream for the process. Must not be null.- Returns:
- this
-
getErrorOutput
@Internal public java.io.OutputStream getErrorOutput()
Returns the output stream to consume standard error from the process executing the command. Default toSystem.err
.- Specified by:
getErrorOutput
in interfaceBaseExecSpec
- 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 interfaceBaseExecSpec
- Parameters:
ignoreExitValue
- whether a non-zero exit value is ignored, or an exception thrown- Returns:
- this
-
isIgnoreExitValue
@Input public boolean isIgnoreExitValue()
Tells whether a non-zero exit value is ignored, or an exception thrown. Defaults tofalse
.- Specified by:
isIgnoreExitValue
in interfaceBaseExecSpec
- Returns:
- whether a non-zero exit value is ignored, or an exception thrown
-
getCommandLine
@Internal public java.util.List<java.lang.String> getCommandLine()
Returns the full command line, including the executable plus its arguments.- Specified by:
getCommandLine
in interfaceBaseExecSpec
- Returns:
- The full command line, including the executable plus its arguments
-
getJvmArgumentProviders
public java.util.List<CommandLineArgumentProvider> getJvmArgumentProviders()
Command line argument providers for the java process to fork.- Specified by:
getJvmArgumentProviders
in interfaceJavaForkOptions
-
getJvmArguments
public ListProperty<java.lang.String> getJvmArguments()
Extra JVM arguments to be to use to launch the JVM for the process. Must be used to set a convention for JVM arguments.- Specified by:
getJvmArguments
in interfaceJavaExecSpec
-
getExecutionResult
@Internal public Provider<ExecResult> getExecutionResult()
Returns the result for the command run by this task. The provider has no value if this task has not been executed yet.- Returns:
- A provider of the result.
- Since:
- 6.1
-
getJavaLauncher
public Property<JavaLauncher> getJavaLauncher()
Configures the java executable to be used to run the tests.- Since:
- 6.7
-
getObjectFactory
@Inject protected ObjectFactory getObjectFactory()
-
getExecActionFactory
@Inject protected org.gradle.process.internal.ExecActionFactory getExecActionFactory()
-
getJavaToolchainService
@Inject protected JavaToolchainService getJavaToolchainService()
-
getProviderFactory
@Inject protected ProviderFactory getProviderFactory()
-
-