-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
101 lines (93 loc) · 2.82 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
buildscript {
ext {
asciidoctorjVersion = '1.5.6'
asciidoctorjPdfVersion = '1.5.0-alpha.16'
asciidoctorGroovyDslVersion = '1.0.0.Alpha2'
}
repositories {
jcenter()
}
dependencies {
classpath "org.asciidoctor:asciidoctorj:$asciidoctorjVersion"
classpath "org.asciidoctor:asciidoctorj-pdf:$asciidoctorjPdfVersion"
classpath "org.asciidoctor:asciidoctorj-groovy-dsl:$asciidoctorGroovyDslVersion"
}
}
plugins {
id 'base'
}
ext {
asciidoctorAttributes = [
'common': [
'doctype' : 'book',
'icons' : 'font',
'attribute-missing' : 'warn',
],
'html': [
'stylesdir' : 'css',
'linkcss' : '',
],
'pdf': [
'source-highlighter': 'rouge',
'doctype' : 'book',
'toc' : '',
'showlinks' : '',
'nonhtmloutput' : '',
]
]
}
def getAsciidoctor() {
if (!project.hasProperty('adoc')) { ext.adoc = org.asciidoctor.Asciidoctor.Factory.create() }
ext.adoc
}
task html {
description 'Build HTML'
ext.sourceDir = "${projectDir}/src"
ext.sourceFile = new File("${sourceDir}/asciidoc/index.adoc")
ext.outputDir = "${buildDir}/html"
inputs.dir sourceDir
outputs.dir outputDir
doLast {
def attrs = asciidoctorAttributes.common + asciidoctorAttributes.html + [
'imagesdir' : 'images',
]
def opts = org.asciidoctor.OptionsBuilder.options()
.backend('html5')
.safe(org.asciidoctor.SafeMode.UNSAFE)
.toDir(new File(outputDir))
.mkDirs(true)
.attributes(attrs)
getAsciidoctor().convertFile(sourceFile, opts.get())
}
doLast {
copy {
from(sourceDir) {
include 'images/**'
}
into outputDir
}
}
}
task pdf {
description 'Build PDF.'
ext.sourceDir = "${projectDir}/src"
ext.sourceFile = new File("${sourceDir}/asciidoc/index.adoc")
ext.imagesDir = "${sourceDir}/images"
ext.outputDir = "${buildDir}/pdf"
ext.otputFile = "$outputDir/cypher-language-specification.pdf"
inputs.dir sourceDir
outputs.dir outputDir
doLast {
def attrs = asciidoctorAttributes.common + asciidoctorAttributes.pdf + [
'imagesdir' : imagesDir.toString(),
]
def opts = org.asciidoctor.OptionsBuilder.options()
.backend('pdf')
.safe(org.asciidoctor.SafeMode.UNSAFE)
.toFile(new File(otputFile))
.mkDirs(true)
.attributes(attrs)
getAsciidoctor().convertFile(sourceFile, opts.get())
}
}
// vim: set fdm=expr: