The YAML Validator Plugin was designed to help you find errors in your YAML files, before your program reaches development stages. This way annoying YAML errors during program startup can be prevented.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.at.zierler:yaml-validator-plugin:1.5.0"
}
}
apply plugin: "at.zierler.yamlvalidator"
plugins {
id "at.zierler.yamlvalidator" version "1.5.0"
}
After including the plugin in your build.gradle
like above, the YAML check can be run with: gradle validateYaml
.
When the java plugin, or any other plugin which introduces a check
task, is included the validateYaml
task will automatically run during the check
task.
To run the validateYaml
automatically during a task other than check
, you can add the following to your build.gradle
:
<any-existing-task>.dependsOn validateYaml
The following are all possible configuration options:
Name | Default value | Description |
---|---|---|
searchPaths | ['src/main/resources/'] | Array of all directories which should be searched for YAML files, or direct paths to single YAML files. |
allowDuplicates | false | Allow YAML files, which contain a duplicate key when checking. |
searchRecursive | false | Search directories defined in `searchPaths` recursively. |
Those are the configuration options, as in an build.gradle
file, with their default values:
yamlValidator {
searchPaths = ['src/main/resources/']
allowDuplicates = false
searchRecursive = false
}
All messages are logged in logging level INFO and higher by default. To see all outputs please use: gradle validateYaml --info
.