-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle
130 lines (104 loc) · 3.97 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import org.asciidoctor.gradle.jvm.AsciidoctorTask
import java.text.SimpleDateFormat
plugins {
id "org.asciidoctor.jvm.base" version "3.3.2"
id "org.asciidoctor.jvm.convert" version "3.3.2"
id "org.asciidoctor.jvm.pdf" version "3.3.2"
id "java"
id "groovy"
}
repositories {
mavenCentral()
}
asciidoctorj {
version = '2.5.3'
}
ext {
today = new Date()
versionDate = new SimpleDateFormat("yyyyMMdd").format(today)
project.version = project.file("./document.version").text
curriculumFileName = "glossary"
addSuffixToCurriculum = { suffix ->
for (extension in ["html", "pdf"]) {
File source = new File("${buildDir}/${curriculumFileName}.${extension}")
File target = new File("${buildDir}/${curriculumFileName}${suffix}.${extension}")
source.renameTo(target)
}
}
}
dependencies {
implementation platform('org.apache.groovy:groovy-bom:4.0.5')
implementation 'org.apache.groovy:groovy'
implementation 'org.apache.groovy:groovy-json:3.0.9'
testImplementation platform("org.spockframework:spock-bom:2.3-groovy-4.0")
testImplementation "org.spockframework:spock-core"
testImplementation "org.apache.groovy:groovy-json:4.0.3"
}
task generateTranslationTables(dependsOn: compileGroovy, type: JavaExec) {
jvmArgs = ['--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.io=ALL-UNNAMED',
'--add-opens', 'java.base/java.util=ALL-UNNAMED']
classpath = sourceSets.main.runtimeClasspath
mainClass = 'Translator'
}
class RenderCurriculumTask extends AsciidoctorTask {
@Inject
RenderCurriculumTask(WorkerExecutor we, String curriculumFileName, String versionDate, String language, boolean withRemarks) {
super(we)
forkOptions {
jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED"
}
sourceDir = new File("./docs/")
baseDir = new File ("./docs/")
sources {
include "index.adoc"
include "${curriculumFileName}.adoc"
}
outputDir = new File("./build/")
outputOptions {
separateOutputDirs = false
backends 'pdf', 'html5'
}
def fileVersion = project.version.trim() + "-" + language
attributes = [
'icons' : 'font',
'version-label' : '',
'revnumber' : fileVersion,
'revdate' : versionDate,
'document-version' : fileVersion + "-" + versionDate,
'currentDate' : versionDate,
'language' : language,
'withRemarks' : withRemarks,
'curriculumFileName': curriculumFileName,
'debug_adoc' : false,
'pdf-stylesdir' : '../pdf-theme/themes',
'pdf-fontsdir' : '../pdf-theme/fonts',
'pdf-style' : 'isaqb',
'stylesheet' : '../html-theme/adoc-github.css',
'stylesheet-dir' : '../html-theme',
'front-cover-image': '../cover/cover_' + language.toLowerCase() + '.pdf'
]
}
}
task buildDocs {
group 'Documentation'
description 'Grouping task for generating all languages in several formats'
dependsOn "generateTables", "renderDE", "renderEN"
}
task renderDE(type: RenderCurriculumTask,
constructorArgs: [curriculumFileName, versionDate, "DE", false]) {
doLast {
addSuffixToCurriculum("-de")
}
dependsOn "sortTermsAlphabetically"
}
task renderEN(type: RenderCurriculumTask,
constructorArgs: [curriculumFileName, versionDate, "EN", false]) {
doLast {
addSuffixToCurriculum("-en")
}
dependsOn "sortTermsAlphabetically"
}
apply from: 'scripts/generateTermTables.gradle'
apply from: 'scripts/sortTermsAlphabetically.gradle'
defaultTasks "buildDocs"