Fork me on GitHub

HTTP Plugin

Do you need to make HTTP requests from your build environment? Do you like HttpBuilder-NG? Do you like Gradle? Well then this plugin is for you! It allows the configuration and execution of HTTP requests as Gradle tasks, using HttpBuilder-NG and any of its supported client implementation libraries.

Features

The plugin encapsulates the functionality of the HttpBuilder-NG library and has access to most of its features, summarized below:

Installation

The Gradle HTTP plugin is available via the Gradle Plugins Repository (io.github.http-builder-ng.http-plugin). It can be applied to your build.gradle file with the following:

plugins {
    id "io.github.http-builder-ng.http-plugin" version "0.1.1"
}

Usage

Once you have applied the plugin to your build, you need to create a custom task to use it. The following code would create a task called "notify", which would send a POST request to http://something.com/notify with the specified body content whenever the task is executed.

task notify(type:HttpTask){
    config {
        request.uri = 'http://something.com'
    }
    post {
        request.uri.path = '/notify'
        request.body = [event: 'activated']
        response.success {
            println 'The event notification was successful'
        }
    }
}

The User Guide provides more detailed information about configuring and using the plugin.