Movatterモバイル変換


[0]ホーム

URL:


JavaExec

Table of Contents

Properties
Methods
Script blocks
Property details
Method details
API Documentation:JavaExec

Executes a Java application in a child process.

Similar toExec, 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'}// Using and creating an Executable Jarjar {  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 (seeJavaExec.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 inJavaExec.debugOptions(org.gradle.api.Action):

task runApp(type: JavaExec) {   ...   debugOptions {       enabled = true       port =5566       server = true       suspend = false   }}

Properties

PropertyDescription
allJvmArgs

The full set of arguments to use to launch the JVM for the process. This includes arguments to definesystem 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 whenthis 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 — debug = true — the processis started in a suspended state, listening on port 5005. You should disable parallel test execution whendebugging and you will need to reattach the debugger occasionally if you use a non-zero value forTest.getForkEvery().

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 toSystem.err.

executable

The name of the executable to use.

ignoreExitValue

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

jvmArgs

The extra arguments to use to launch the JVM for the process. Does not include system properties and theminimum/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 processcompletes. Defaults to an empty stream.

standardOutput

The output stream to consume standard output from the process executing the command. Defaults toSystem.out.

systemProperties

The system properties which will be used for the process.

workingDir

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

Methods

MethodDescription
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 perProject.file(java.lang.Object).

Script blocks

No script blocks

Property details

List<String>allJvmArgs

The full set of arguments to use to launch the JVM for the process. This includes arguments to definesystem properties, the minimum/maximum heap size, and the bootstrap classpath.

The arguments passed to the main class to be executed.

Default:
[]

List<CommandLineArgumentProvider>argumentProviders (read-only)

Argument providers for the application.

Default:
[]

FileCollectionbootstrapClasspath

The bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used whenthis classpath is empty.

Default:
[]

The classpath for executing the main class.

Default:
null

List<String>commandLine (read-only)

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

booleandebug

Determines whether debugging is enabled for the test process. When enabled — debug = true — the processis started in a suspended state, listening on port 5005. You should disable parallel test execution whendebugging 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 viaJavaForkOptions.debugOptions(org.gradle.api.Action).

Default:
false

booleanenableAssertions

Returns true if assertions are enabled for the process.

Default:
false

Map<String,Object>environment

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

Default:
Current process' environment

OutputStreamerrorOutput

The output stream to consume standard error from the process executing the command. Default toSystem.err.

Default:
System.err

Stringexecutable

The name of the executable to use.

Default:
java executable for current JVM

booleanignoreExitValue

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

Default:
false

List<String>jvmArgs

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

Default:
[]

List<CommandLineArgumentProvider>jvmArgumentProviders (read-only)

Command line argument providers for the java process to fork.

Default:
[]

Stringmain

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

This does not need to be set if using anExecutable Jar with aMain-Class attribute.

Default:
null

StringmaxHeapSize

The maximum heap size for the process, if any.

Default:
null

InputStreamstandardInput

The standard input stream for the process executing the command. The stream is closed after the processcompletes. Defaults to an empty stream.

Default:
An emptyInputStream

OutputStreamstandardOutput

The output stream to consume standard output from the process executing the command. Defaults toSystem.out.

Default:
System.out

Map<String,Object>systemProperties

The system properties which will be used for the process.

Default:
[:]

FileworkingDir

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

Default:
project.projectDir

Method details

JavaExecSpecargs(Iterable<?> args)

Adds args for the main class to be executed.

JavaExecargs(Object... args)

Adds args for the main class to be executed.

JavaExecbootstrapClasspath(Object... classpath)

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

JavaExecclasspath(Object... paths)

Adds elements to the classpath for executing the main class.

JavaExeccopyTo(JavaForkOptions options)

Copies these options to the given options.

Copies these options to the given target options.

JavaExecenvironment(String name,Object value)

Adds an environment variable to the environment for this process.

JavaExecenvironment(Map<String, ?> environmentVariables)

Adds some environment variables to the environment for this process.

JavaExecexecutable(Object executable)

Sets the name of the executable to use.

JavaExecjvmArgs(Iterable<?> arguments)

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

JavaExecjvmArgs(Object... arguments)

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

JavaExecsystemProperties(Map<String, ?> properties)

Adds some system properties to use for the process.

JavaExecworkingDir(Object dir)

Sets the working directory for the process. The supplied argument is evaluated as perProject.file(java.lang.Object).


[8]ページ先頭

©2009-2025 Movatter.jp