This documentation covers a prerelease version of the software. Follow this link to view the documentation for the stable version (4.0) instead.

Adding an external backend as an output formatter

Although the popular AsciidoctorJ backends are supported in this plugin suite, there is a good chance that one might want to use a backend that is not directly supported. For this there is a special output formatter of type AsciidoctorjGenericOutputFormatter.

import org.asciidoctor.gradle.model5.jvm.formatters.AsciidoctorjGenericOutputFormatter
import org.asciidoctor.gradle.model5.jvm.toolchains.AsciidoctorjToolchain

asciidoc {
  toolchains {
    asciidoctorj.registeredOutputFormatters {
      myBackend(AsciidoctorjGenericOutputFormatter) {
        backend = 'foo' (1)
        attributes( foo_color : 'black') (2)
        copyResources = false (3)
        enforcedDocType = 'book' (4)
        requires 'foo' (5)
        useGem 'foo', '1.2.3' (6)
        useModule( 'acme.foo:foo', '1.2.3') (7)
        useModule( dependencies.project(':my-backend')) (8)
      }
    }
  }
}
1 Set the name of the backend
2 Set the specific attributes that this backend might require.
3 Set whether the backend should copy resources.
4 If the backend requires a specific kind of document type, set it here, otherwise leave it alone.
5 If one or more requires need to be passed to the engine, define them here.
6 If the backend is only available as a GEM, add the name of the GEM and its version. To use this option, the org.asciidoctor.jvm.gems must be applied.
7 If the backend is available as a JAR artifact from a Maven or Ivy repository, provide the Maven module coordinates as well as something that will resolve to a version string.
8 If the backend is provided from the current project hierarchy, it can be referenced as a project dependency.