Using asciidoctor gradle plugin with spring restdocs extension and the gradle kotlin dsl.

plugins {
  id("org.asciidoctor.jvm.convert") version "3.2.0"
}

val asciidoctorExtensions by configurations.creating

dependencies {
  asciidoctorExtensions("org.springframework.restdocs:spring-restdocs-asciidoctor:2.0.5.RELEASE")
}

tasks {
  asciidoctor {
    dependsOn("test")
    inputs.dir(File("$buildDir/generated-snippets"))
    configurations("asciidoctorExtensions")
    asciidoctorj {
      baseDirFollowsSourceFile()
    }
    resources(delegateClosureOf<CopySpec> {
      from("src/docs/asciidoc") {
        include("**/img/**")
        include("**/data/**")
      }
    })
  }
}