Select Git revision
test_all.pl
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
build.gradle 2.97 KiB
import freemarker.template.Configuration
import org.yaml.snakeyaml.Yaml
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.freemarker:freemarker:2.3.30'
classpath 'org.yaml:snakeyaml:1.27'
}
}
plugins {
id "org.asciidoctor.jvm.convert" version "3.1.0"
id "org.asciidoctor.jvm.gems" version "3.1.0"
}
wrapper {
gradleVersion = "6.8.1"
distributionType = Wrapper.DistributionType.ALL
}
def cfg = new Configuration()
repositories {
mavenCentral()
ruby.gems()
}
configurations {
asciidoctorDeps
}
dependencies {
asciidoctorDeps 'org.asciidoctor:asciidoctorj-diagram:2.1.0'
asciidoctorDeps 'org.asciidoctor:asciidoctorj-epub3:1.5.0-alpha.19'
asciidoctorDeps 'org.asciidoctor:asciidoctorj-pdf:1.5.4'
asciidoctorGems 'rubygems:asciidoctor-bibtex:0.8.0'
}
asciidoctorj {
version = '2.4.2'
}
task bibtex() {
def inputDir = file("src/docs/bibtex")
def combinedFile = file("src/docs/asciidoc/combined.bib")
inputs.dir(inputDir)
outputs.file(combinedFile)
doFirst {
combinedFile.text = fileTree(inputDir) {
include "**/*.bib"
}.collect {it.text}.join("\n")
}
}
task buildMaindocs() {
def templateFileName = "src/docs/templates/handbook.ftlh"
def configFile = file("config.yaml")
def chapterDir = file("src/docs/chapter")
def outputDir = file("src/docs/asciidoc")
inputs.files(templateFileName, configFile)
inputs.dir(chapterDir)
outputs.dir(outputDir)
doLast {
def template = cfg.getTemplate(templateFileName)
def parser = new Yaml()
def books = parser.loadAll(configFile.text)
books.each {book ->
def includes = []
book.content.each {dir ->
includes << fileTree(new File(chapterDir, dir)).collect().sort()
}
book.directories = includes
new File(outputDir, book.file).withWriter("UTF-8") {w ->
template.process(book, w)
}
}
}
}
asciidoctor {
dependsOn = [bibtex, asciidoctorGemsPrepare, buildMaindocs]
configurations "asciidoctorDeps"
options doctype: 'book'
outputOptions {
backends = ['html5', 'pdf']
}
asciidoctorj {
requires = ['asciidoctor-diagram', 'asciidoctor-bibtex']
attributes = [
'source-highlighter': 'coderay',
'coderay-linenums-mode': 'table',
'toc': 'left',
'imagesdir': 'images',
'icon': 'font',
'linkattrs': true,
'encoding': 'utf-8',
'bibtex-file': 'combined.bib',
]
}
baseDirFollowsSourceDir()
sources {
include '*.adoc'
}
resources {
from('src/docs/asciidoc') {
include '**/*.png'
}
}
}
clean {
delete(fileTree('src/docs/asciidoc') {
include '*.adoc'
})
delete('src/docs/asciidoc/combined.bib')
}
defaultTasks 'asciidoctor'