Skip to content
Gradle Processes Plugin - Create and manage forked processes
Branch: master
Clone or download
John Engelman
John Engelman (release): 0.5.0
Latest commit f87abc5 Jul 30, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
src Update to gradle 4.6 api (#13) Jul 30, 2018
.gitignore
.travis.yml
LICENSE
README.md Feature/update to gradle 4.5 api (#10) Feb 10, 2018
build.gradle (release): 0.5.0 Jul 30, 2018
gradlew Feature/update to gradle 4.5 api (#10) Feb 10, 2018
gradlew.bat Feature/update to gradle 4.5 api (#10) Feb 10, 2018
settings.gradle

README.md

gradle-processes

Gradle Processes Plugin - Create and manage forked processes.

This Gradle plugin provides the capability to create forked processes from a Gradle build. It's primary goal is to bolster the built in capabilities of Gradle which allow for processing forking only in a synchronous manner.

Compatibility Notes

This updated version of the plugin is tested against Gradle versions 4.5 onwards (final versions only).

Due to internal gradle API changes (some of which this plugin uses) you have to use the older version 0.3.0 of the plugin on gradle version < 4.5!

How To Use

Starting from gradle 4.5: Apply the plugin to your Gradle build:

plugins {
    id 'com.github.johnrengelman.processes' // TODO add version
}

If using a version prior to gradle 4.5: Apply the plugin to your Gradle build:

plugins {
    id "com.github.johnrengelman.processes" version "0.3.0"
}

Capabilities

Process Forking

ProcessHandle handle = project.procs.fork {
    <process configuration> See [Exec](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.Exec.html)
}

ProcessHandle handle = project.procs.javafork {
    <process configuration> See [JavaExec](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.JavaExec.html)
}

Process Joining

project.procs.waitForFinish(handle)

Handling Multiple Processes

ProcessHandle handle = project.procs.javafork { ... }
ProcessHandle handle2 = project.procs.javafork { ... }
project.procs.waitForFinish([handle, handle2])

Forking Tasks

task fork(type: Fork) {
  // Configure the same as the Exec task
}

task javafork(type: JavaFork) {
  // Configure the same as the JavaExec task
}

Accessing a Forked Tasks Process

task fork(type: Fork) {
  // Configure task
}

task waitForFork() << {
  fork.processHandle.waitForFinish()
}

Using the forked tasks can allow for starting/stopping processes for things like test infrastructure.

task startServer(type: Fork) {
  // Start some external service
}

task stopServer << {
  startServer.processHandle.abort()
}

test.dependsOn startServer
test.finalizedBy stopServer

Building the plugin

This should build everything and run the tests:

./gradlew build
You can’t perform that action at this time.