Kane
Kane

Reputation: 8172

How to fail gradle build if asciidoctor got generating warning

I'm using spring-restdocs to generate docs.

I'm wondering if any property to fail the asciidoctor task while getting similar warnings when building the doc.

Snippet http-response not found at ../../../build/generated-snippets/find-list-configuration-fixed-assets-source-response/http-response.adoc for operation find-list-configuration-fixed-assets-source-response
Snippet path-parameters not found at ../../../build/generated-snippets/update-currency/path-parameters.adoc for operation update-currency

Upvotes: 1

Views: 468

Answers (2)

Alexandru Severin
Alexandru Severin

Reputation: 6218

This is possible starting with asciidoctor 2.0, by configuring the fatalWarnings option of asciidoctorj.

Documentation of fatalWarnings:

Patterns for AsciidoctorJ log messages that should be treated as fatal errors. The list is empty be default. Use setFatalWarnings to clear any existing patterns or to decouple a task’s configuration from the global configuration. Use fatalWarnings to add more patterns. Pass missingIncludes() to add the common use-case of missing include files.

Example:

asciidoctor {
  asciidoctorj {
      fatalWarnings missingIncludes()
  }
}

Upvotes: 0

Unfortunately, this is not possible. There is an open issue https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/154 since 2015. If you read through this issue you will find a workaround. Maybe it will help you. :-)

Upvotes: 1

Related Questions