generateDocbook

Jody Winter Jeremie Bresson Ralf D. Müller

1 minute to read

At a Glance

generateDocBook

About This Task

A helper task, generateDocbook generates the intermediate format for convertToDocx<<>> and convertToEpub.

Source

AsciiDocBasics.gradle
task generateDocbook (
        type: AsciidoctorTask,
        group: 'docToolchain',
        description: 'use docbook as asciidoc backend') {

    def sourceFilesDOCBOOK = findSourceFilesByType(['docbook', 'epub', 'docx'])
//    onlyIf {
//        sourceFilesDOCBOOK
//    }

    sources {
        sourceFilesDOCBOOK.each {
            include it.file
            logger.info it.file

            File useFile = new File(srcDir, it.file)
            if (!useFile.exists()) {
                throw new Exception ("""
                The file $useFile in DOCBOOK config does not exist!
                Please check the configuration 'inputFiles' in $mainConfigFile.""")
            }
        }
    }

    outputOptions {
        backends = ['docbook']
    }

    outputDir = file(targetDir+'/docbook/')

    doFirst {
        if (sourceFilesDOCBOOK.size()==0) {
            throw new Exception ("""
            >> No source files defined for type of '[docbook, epub, docx]'.
            >> Please specify at least one inputFile in your docToolchainConfig.groovy
            """)
        }
    }
}