Coder Social home page Coder Social logo

pmjpmj / gradle-spawn-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marc0der/gradle-spawn-plugin

0.0 1.0 0.0 118 KB

Gradle plugin for spawning and killing command line processes.

License: Apache License 2.0

Groovy 98.53% Shell 1.47%

gradle-spawn-plugin's Introduction

##Gradle Spawn Plugin

This plugin is used for starting and stopping UNIX command line processes from within your build.

A typical application of this plugin is for stopping and starting an embedded web server when running functional tests from within your build.

###Setup

Add the following to your build.gradle:

import com.wiredforcode.gradle.spawn.*

buildscript {
	repositories {
		...
		maven { url 'http://dl.bintray.com/vermeulen-mp/gradle-plugins' }
	}
	dependencies {
		classpath 'com.wiredforcode:gradle-spawn-plugin:0.6.0'
	}
}

apply plugin: 'com.wiredforcode.spawn'

task startServer(type: SpawnProcessTask, dependsOn: 'assemble') {
	command "java -jar ${projectDir}/build/libs/zim-service.jar"
	ready 'Started Application'
}

task stopServer(type: KillProcessTask)

The startServer task is used for starting the process.

The command line passed into the command method is typically a blocking process. The String passed into the ready method is the trigger used for continuing the build once the server process is up and running. If this String is discovered in the stdout stream of the server, the process will be placed into the background and the Gradle build will continue.

Once the build draws to a close, the stopServer task is then used to gracefully shut down the server process.

###PID File

The SpawnProcessTask will automatically deposit a .pid.lock file in the working directory. This contains the PID of the running process. The KillProcessTask will read this lock file, kill the process gracefully, and remove the file.

It is also possible to set the name of the pid file allowing more than one process to be opened.

task startServer(type: SpawnProcessTask, dependsOn: 'assemble') {
	command "java -jar ${projectDir}/build/libs/zim-service.jar"
	ready 'Started Application'
	pidLockFileName '.other.pid.lock'
}

gradle-spawn-plugin's People

Contributors

breskeby avatar chiquitinxx avatar marc0der avatar tomaslin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.