Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Ensures that your Gradle build never runs forever. For whatever reason

License

Notifications You must be signed in to change notification settings

dotanuki-labs/gradle-timeouts-enforcer

Repository files navigation

Gradle Timeouts Enforcer Plugin

Warning

This project is no longer maintened. Please fork it at will

What

A simple Gradle plugin that enforces timeouts for all the tasks defined on your Gradle build.

Using

Step 01 : Add this property at your <root-project>/gradle.properties file

io.dotanuki.gradle.timeouts.tasks=10.minutes

For this property you probably want to assign a value based on your slowest build task(s).

Step 02 : Apply this plugin into your build at your root level Gradle build.

  • For <root-project>/build.gradle
plugin {
    id 'io.labs.dotanuki.timeoutsenforcer' version '<plugin_version>'
}
  • For <root-project>/build.gradle.kts
plugin {
    id("io.labs.dotanuki.timeoutsenforcer") version "<plugin_version>"
}

Step 03 : Profit 🚀

Check releases for the latest plugin version. More instructions also available in the plugin page

Providing Timeouts

For the Gradle property this plugin reads, the specified value must follow the amount.unit convention, where

(a) supported unit include :

  • second, seconds (upper / lower / camel cases)
  • minute, minutes (upper / lower / camel cases)
  • hour, hours (upper / lower / camel cases)

(b) amount should be an integer value

Examples of valid specifications

  • 1.hour
  • 10.SECONDS
  • 30.Minutes

Examples of invalid specifications

  • 1.5.hour
  • 30,5.minutes

This plugin will parse and validate the provided specification and throw an error if it does not match expected conventions.

Supported Gradle versions

This plugin supports only Gradle 5.x.y or newer.

See it in action

To quick test this plugin in a real project, a sampleis provided :

$> cd sample
$> ./gradlew clean run

Sample will emulate a long task (15 seconds to complete run), but this task will fail after 10 seconds, as defined in sample/gradle.properties.

➜  sample git:(master) ✗ ./gradlew clean run
Configuration on demand is an incubating feature.

> Task :run FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Timeout has been exceeded

Author

Coded by Ubiratan Soares (follow me on Twitter)

License

The MIT License (MIT)

Copyright (c) 2020 Dotanuki Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.