Stop a Gradle Build with an Error: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=Internal= * Gradle Programming =Overview= To stop Gradle in the configuration ph...") |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Internal= | =Internal= | ||
* [[Gradle_Programming#Stop_a_Gradle_Build_with_an_Error|Gradle Programming]] | * [[Gradle_Programming TODEPLETE#Stop_a_Gradle_Build_with_an_Error|Gradle Programming]] | ||
=Overview= | =Overview= | ||
To stop Gradle in the [[Gradle_Concepts#Configuration|configuration]] phase with an error, usually caused by user input, or missing configuration: | To stop Gradle in the [[Gradle_Concepts#Configuration|configuration]] phase with an error, usually caused by user input, or missing configuration, throw the relevant exception from [https://docs.gradle.org/current/javadoc/org/gradle/api/package-summary.html org.gradle.api] package: | ||
* [http://gradle.org/docs/current/javadoc/org/gradle/api/InvalidUserDataException.html InvalidUserDataException] | |||
* [http://gradle.org/docs/current/javadoc/org/gradle/api/GradleScriptException.html GradleScriptException] | |||
=Example= | |||
<syntaxhighlight lang='groovy'> | |||
ext { | |||
String s = System.getenv("REQUIRED_ENVIRONMENT_VARIABLE"); | |||
if (s == null) { | |||
throw new InvalidUserDataException("this Gradle build requires 'REQUIRED_ENVIRONMENT_VARIABLE' environment variable to be defined and meaningful, but the variable was not found in the environment!"); | |||
} | |||
} | |||
</syntaxhighlight> | |||
=Organizatorium= | |||
* [http://gradle.org/docs/current/javadoc/org/gradle/api/tasks/StopActionException.html StopActionException] | |||
* [http://www.gradle.org/docs/current/javadoc/org/gradle/api/tasks/TaskExecutionException.html TaskExecutionException] |
Latest revision as of 00:08, 9 November 2020
Internal
Overview
To stop Gradle in the configuration phase with an error, usually caused by user input, or missing configuration, throw the relevant exception from org.gradle.api package:
Example
ext {
String s = System.getenv("REQUIRED_ENVIRONMENT_VARIABLE");
if (s == null) {
throw new InvalidUserDataException("this Gradle build requires 'REQUIRED_ENVIRONMENT_VARIABLE' environment variable to be defined and meaningful, but the variable was not found in the environment!");
}
}