Configure Toolchains

Toolchain basics

Toolchains are added via additional plugins. For instance the org.asciidoctor.jvm plugin will add the toolchain for converting Asciidoc source using the AsciidoctorJ engine. The same plugin will also add html, docbook and manpage output formats for that toolchain.

Users do not usually need to create toolchains directly, but might need to configure specific toolchains or output formatters. (Output formatters are effectively what is also know as Asciidoctor backends).

In some special cases a user might want to create another toolchain of the same type, but configure it differently.

import org.asciidoctor.gradle.model5.jvm.toolchains.AsciidoctorjToolchain (1)

asciidoc {
  toolchains {
    asciidoctorj { (2)

    }
    asciidoctorj2(AsciidoctorjToolchain) {  (3)

    }
  }
}
1 Only needed if you plan to add additional toolchains yourself.
2 Configure the asciidoctorj toolchain that is supplied via the org.asciidoctor.jvm plugin.
3 Create a second AsciidoctorJ toolchain and configure it differently than the default.

Output formatter basics

Output formats are registered on each toolchain. For instance, the org.asciidoctor.jvm.pdf plugin adds a pdf output formatter, which can then be configured.

import org.asciidoctor.gradle.model5.jvm.formatters.AsciidoctorjPdf

asciidoc {
  toolchains {
    asciidoctorj {
        registeredOutputFormatters.named('pdf', AsciidoctorjPdf) {
           useTheme('default-with-font-fallbacks')
        }
    }
  }
}