Package org.gradle.process

# Interface JavaForkOptions

All Superinterfaces:
  `ProcessForkOptions`

All Known Subinterfaces:
  `JavaExecSpec`

All Known Implementing Classes:
  `JavaExec`, `Test`

public interface JavaForkOptions extends ProcessForkOptions

Specifies the options to use to fork a Java process.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `JavaForkOptions`
  `bootstrapClasspath(@Nullable Object... classpath)`
  Adds the given values to the end of the bootstrap classpath for the process.
  `JavaForkOptions`
  `copyTo(JavaForkOptions options)`
  Copies these options to the given options.
  `void`
  `debugOptions(Action<JavaDebugOptions> action)`
  Configures Java Debug Wire Protocol properties for the process.
  `Provider<List<String>>`
  `getAllJvmArgs()`
  Returns the full set of arguments to use to launch the JVM for the process.
  `ConfigurableFileCollection`
  `getBootstrapClasspath()`
  Returns the bootstrap classpath to use for the process.
  `Property<Boolean>`
  `getDebug()`
  Determines whether debugging is enabled for the test process.
  `JavaDebugOptions`
  `getDebugOptions()`
  Returns the Java Debug Wire Protocol properties for the process.
  `Property<String>`
  `getDefaultCharacterEncoding()`
  Returns the default character encoding to use.
  `Property<Boolean>`
  `getEnableAssertions()`
  A flag that marks if assertions are enabled for the process.
  `ListProperty<String>`
  `getJvmArgs()`
  The extra arguments to use to launch the JVM for the process.
  `ListProperty<CommandLineArgumentProvider>`
  `getJvmArgumentProviders()`
  Command line argument providers for the java process to fork.
  `Property<String>`
  `getMaxHeapSize()`
  Returns the maximum heap size for the process, if any.
  `Property<String>`
  `getMinHeapSize()`
  Returns the minimum heap size for the process, if any.
  `MapProperty<String,Object>`
  `getSystemProperties()`
  System properties which will be used for the process.
  `JavaForkOptions`
  `jvmArgs(Iterable<?> arguments)`
  Adds some arguments to use to launch the JVM for the process.
  `JavaForkOptions`
  `jvmArgs(Object... arguments)`
  Adds some arguments to use to launch the JVM for the process.
  `void`
  `setAllJvmArgs(Iterable<?> arguments)`
  Deprecated.
  `void`
  `setAllJvmArgs(List<String> arguments)`
  Deprecated.
  `void`
  `setBootstrapClasspath(FileCollection bootstrapClasspath)`
  Sets the bootstrap classpath to use for the process.
  `void`
  `setDebug(boolean debug)`
  Enable or disable debugging for the process.
  `void`
  `setDefaultCharacterEncoding(@Nullable String defaultCharacterEncoding)`
  Sets the default character encoding to use.
  `void`
  `setEnableAssertions(boolean enableAssertions)`
  Enable or disable assertions for the process.
  `void`
  `setJvmArgs(Iterable<?> arguments)`
  Sets the extra arguments to use to launch the JVM for the process.
  `void`
  `setJvmArgs(List<String> arguments)`
  Sets the extra arguments to use to launch the JVM for the process.
  `void`
  `setMaxHeapSize(@Nullable String maxHeapSize)`
  Sets the maximum heap size for the process.
  `void`
  `setMinHeapSize(@Nullable String minHeapSize)`
  Sets the minimum heap size for the process.
  `void`
  `setSystemProperties(Map<String,? extends @Nullable Object> systemProperties)`
  Sets the system properties to use for the process.
  `JavaForkOptions`
  `systemProperties(Map<String,? extends @Nullable Object> properties)`
  Adds some system properties to use for the process.
  `JavaForkOptions`
  `systemProperty(String name, @Nullable Object value)`
  Adds a system property to use for the process.

  ### Methods inherited from interface org.gradle.process.ProcessForkOptions

  `copyTo, environment, environment, executable, getEnvironment, getExecutable, getWorkingDir, getWorkingDirectory, setEnvironment, setExecutable, setExecutable, setWorkingDir, setWorkingDir, workingDir`

- ## Method Details

  - ### getSystemProperties

    @Input MapProperty<String,Object> getSystemProperties()
    System properties which will be used for the process.
    Returns:
      The system properties. Returns an empty map when there are no system properties.

  - ### setSystemProperties

    void setSystemProperties(Map<String,? extends @Nullable Object> systemProperties)
    Sets the system properties to use for the process.
    Parameters:
      `systemProperties` - The system properties. Must not be null.

  - ### systemProperties

    JavaForkOptions systemProperties(Map<String,? extends @Nullable Object> properties)
    Adds some system properties to use for the process.
    Parameters:
      `properties` - The system properties. Must not be null.
    Returns:
      this

  - ### systemProperty

    JavaForkOptions systemProperty(String name, @Nullable Object value)
    Adds a system property to use for the process.
    Parameters:
      `name` - The name of the property
      `value` - The value for the property. May be null.
    Returns:
      this

  - ### getDefaultCharacterEncoding

    @Optional @Input Property<String> getDefaultCharacterEncoding()
    Returns the default character encoding to use.
    Returns:
      The default character encoding. Returns null if the `default character encoding of this JVM` should be used.

  - ### setDefaultCharacterEncoding

    void setDefaultCharacterEncoding(@Nullable 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, the `file.encoding` property). For JVMs where this is the case, setting the `file.encoding` property via `setSystemProperties(java.util.Map)` or similar will have no effect as this value will be overridden by the value specified by `getDefaultCharacterEncoding()`.
    Parameters:
      `defaultCharacterEncoding` - The default character encoding. Use null to use `this JVM's default charset`

  - ### getMinHeapSize

    @Optional @Input Property<String> getMinHeapSize()
    Returns the minimum heap size for the process, if any. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
    Returns:
      The minimum heap size. Returns null if the default minimum heap size should be used.

  - ### setMinHeapSize

    void setMinHeapSize(@Nullable String minHeapSize)
    Sets the minimum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
    Parameters:
      `minHeapSize` - The minimum heap size. Use null for the default minimum heap size.

  - ### getMaxHeapSize

    @Optional @Input Property<String> getMaxHeapSize()
    Returns the maximum heap size for the process, if any. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
    Returns:
      The maximum heap size. Returns null if the default maximum heap size should be used.

  - ### setMaxHeapSize

    void setMaxHeapSize(@Nullable String maxHeapSize)
    Sets the maximum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
    Parameters:
      `maxHeapSize` - The heap size. Use null for the default maximum heap size.

  - ### getJvmArgs

    @Optional @Input ListProperty<String> getJvmArgs()
    The extra arguments to use to launch the JVM for the process.
    Returns:
      The list of arguments. Returns an empty list if there are no arguments.

  - ### setJvmArgs

    void setJvmArgs(List<String> arguments)
    Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.
    Parameters:
      `arguments` - The arguments. Must not be null.
    Since:
      4.0

  - ### setJvmArgs

    void setJvmArgs(Iterable<?> arguments)
    Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.
    Parameters:
      `arguments` - The arguments. Must not be null.

  - ### jvmArgs

    JavaForkOptions jvmArgs(Iterable<?> arguments)
    Adds some arguments to use to launch the JVM for the process.
    Parameters:
      `arguments` - The arguments. Must not be null.
    Returns:
      this

  - ### jvmArgs

    JavaForkOptions jvmArgs(Object... arguments)
    Adds some arguments to use to launch the JVM for the process.
    Parameters:
      `arguments` - The arguments.
    Returns:
      this

  - ### getJvmArgumentProviders

    ListProperty<CommandLineArgumentProvider> getJvmArgumentProviders()
    Command line argument providers for the java process to fork.
    Since:
      4.6

  - ### getBootstrapClasspath

    @Classpath ConfigurableFileCollection getBootstrapClasspath()
    Returns the bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used when this classpath is empty.
    Returns:
      The bootstrap classpath. Never returns null.

  - ### setBootstrapClasspath

    void setBootstrapClasspath(FileCollection bootstrapClasspath)
    Sets the bootstrap classpath to use for the process. Set to an empty classpath to use the default bootstrap classpath for the specified JVM.
    Parameters:
      `bootstrapClasspath` - The classpath. Must not be null. Can be empty.

  - ### bootstrapClasspath

    JavaForkOptions bootstrapClasspath(@Nullable Object... classpath)
    Adds the given values to the end of the bootstrap classpath for the process.
    Parameters:
      `classpath` - The classpath.
    Returns:
      this

  - ### getEnableAssertions

    @Input @Optional Property<Boolean> getEnableAssertions()
    A flag that marks if assertions are enabled for the process.

  - ### setEnableAssertions

    void setEnableAssertions(boolean enableAssertions)
    Enable or disable assertions for the process.
    Parameters:
      `enableAssertions` - true to enable assertions, false to disable.

  - ### getDebug

    @Input Property<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 for `Test.getForkEvery()`.

    Since Gradle 5.6, you can configure the port and other Java debug properties via `debugOptions(Action)`.

  - ### setDebug

    void setDebug(boolean debug)
    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 `debugOptions(Action)`.

    Parameters:
      `debug` - true to enable debugging, false to disable.

  - ### getDebugOptions

    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.
    Since:
      5.6

  - ### debugOptions

    void debugOptions(Action<JavaDebugOptions> action)
    Configures Java Debug Wire Protocol properties for the process. If `getDebug()` (boolean)} is enabled then the `-agentlib:jdwp=...` will be appended to the JVM arguments with the configuration from the parameter.
    Parameters:
      `action` - the Java debug configuration
    Since:
      5.6

  - ### getAllJvmArgs

    @Internal Provider<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 minimum/maximum heap size, and the bootstrap classpath.
    Returns:
      The immutable list of arguments. Returns an empty list if there are no arguments.

  - ### setAllJvmArgs

    @Deprecated void setAllJvmArgs(List<String> arguments)
    Deprecated.
    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.
    Parameters:
      `arguments` - The arguments. Must not be null.
    Since:
      4.0

  - ### setAllJvmArgs

    @Deprecated void setAllJvmArgs(Iterable<?> arguments)
    Deprecated.
    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.
    Parameters:
      `arguments` - The arguments. Must not be null.

  - ### copyTo

    JavaForkOptions copyTo(JavaForkOptions options)
    Copies these options to the given options.
    Parameters:
      `options` - The target options.
    Returns:
      this