Example of using everything from Model5

This is an example where all the model5 plugins are used together.

build.gradle
import org.asciidoctor.gradle.model5.jvm.toolchains.AsciidoctorjToolchain
import org.asciidoctor.gradle.model5.js.extensions.AsciidoctorjsKrokiExtension
import org.asciidoctor.gradle.model5.jvm.extensions.AsciidoctorjKrokiExtension
import org.asciidoctor.gradle.model5.jvm.formatters.AsciidoctorjPdf

plugins { (1)
    id 'org.asciidoctor.jvm'
    id 'org.asciidoctor.jvm.pdf'
    id 'org.asciidoctor.jvm.revealjs'
    id 'org.asciidoctor.jvm.gems'
    id 'org.asciidoctor.jvm.kroki'
    id 'org.asciidoctor.jvm.epub'
    id 'org.asciidoctor.js'
    id 'org.asciidoctor.js.docbook'
    id 'org.asciidoctor.js.kroki'
    id 'org.asciidoctor.js.revealjs'
    id 'org.asciidoctor.reducer'
    id 'org.asciidoctor.downdoc'
    id 'org.asciidoctor.kramdoc'
}

repositories {
    ruby.gems()
}


kramdownAsciidoc {
    publications {
        main {
            sourceSet {
                sourceDir = 'src/docs/kramdoc'
            }
            output 'kramdown', 'asciidoc'
        }
    }
}

asciidoc {
    toolchains {
        asciidoctorj { (2)
            asciidocExtensions {
                kroki(AsciidoctorjsKrokiExtension) {
                    fetchDiagrams = true
                }
            }

        }
        asciidoctorj2(AsciidoctorjToolchain) { (3)
            registeredOutputFormatters {
                pdf(AsciidoctorjPdf) {
                    allowUriRead = true
                }
            }
        }
    }
    publications {
        main {
            output 'asciidoctorj', 'html'
            output 'asciidoctorj', 'docbook'
            output 'asciidoctorj', 'epub'
            output 'asciidoctorj2', 'pdf'
            output 'asciidoctorjs', 'html', 'html2' (4)
            output 'asciidoctorjs', 'docbook', 'docbook2'

            sourceSet {
                baseDir.baseDirFollowsSourceFiles()
            }
        }
        slides { (5)
            output 'asciidoctorj', 'revealjs'
            output 'asciidoctorjs3', 'revealjs', 'revealjs2'

            sourceSet {
                sourceDir = 'src/docs/slides'
            }
        }
        combined {
            sourceSet {
                sourceDir = 'src/docs/reducer'
            }

            output 'asciidoctorReducer', 'reducedAdoc', 'forDowndoc' (6)
        }
        exportToMarkdown { (7)
            sourceSet {
                externalSource {
                    fromPublication 'combined', 'forDowndoc' (8)
                }
            }
            output 'downdoc', 'markdown' (9)
        }
        fromMarkdown {
            sourceSet {
                externalSource { (10)
                    builtBy 'kramdocAsciidoc'
                    from(tasks.named('kramdocAsciidoc') { outputs.files })
                }
            }
            output 'asciidoctorj', 'html'
        }
    }
}
1 The plugins do not have versions here, purely because in our test example we already have all the plugins on the classpath. You should add versions as appropriate or use aliases with a version catalog.
2 THe asciidoctorj toolchain is automatically added by the 'org.asciidoctor.jvm' conventions plugin.
3 asciidoctorj2 is a second toolchain that is added manually in the build script.
4 Becasue there is already an outputon the publication called html, an alias is added here called html2 and in this case it uses the asciidoctorjs toolchains that is added by the org.asciidoctor.js conventions plugin.
5 A second set of publications purely aimed at producing selides. Because slides ten to be authored slightly differently, it is sometimes just easier to use a separate publication.
6 An example of reducing a nested set of AsciiDoc documents into a single AsciiDoc document. The asciidoctorReducer toolchain and the reducedAdoc output formatter are added vb the org.asciidoctor.reducer conventions plugin. In this case a semantic alias is purely added to be indicative of the target of the reduced document.
7 An example of how AsciiDoc can be reduced to a single AsciiDoc document and then turned into Markdown.
8 Using the output of one output formatter to be the input of another AsciiDoc processor.
9 The downdoc toolchain and the markdown output formatter are added by the org.asciidoctor.downdoc conventions plugin.
10 Using the output from the kramdocAsciidoc task as inputs to this source set. This is an example of how to use converted Markdown as part of AsciiDoc processing.