forked from isaqb-org/curriculum-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
110 lines (92 loc) · 3.69 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
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"
}
repositories {
mavenCentral()
}
asciidoctorj {
version = '2.5.3'
}
ext {
today = new Date()
versionDate = new SimpleDateFormat("yyyyMMdd").format(today)
releaseVersion = System.getenv("RELEASE_VERSION")
localVersion = "LocalBuild"
project.version = releaseVersion == null ? localVersion : releaseVersion;
validity = new Date(project.file("./document.validity").text.trim())
validityEnglish = "valid from " + new SimpleDateFormat("MMMM d, yyyy", Locale.US).format(validity)
validityGerman = "Gültig ab " + new SimpleDateFormat("d. MMMM yyy", Locale.GERMANY).format(validity)
curriculumFileName = "curriculum-foundation"
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)
}
}
}
class RenderCurriculumTask extends AsciidoctorTask {
@Inject
RenderCurriculumTask(WorkerExecutor we, String curriculumFileName, String versionDate, String validity, String language) {
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 + " (" + validity + ")",
'currentDate' : versionDate,
'language' : language,
'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',
'glossary_url' : 'https://public.isaqb.org/glossary/glossary-' + language.toLowerCase() + '.html#term-'
]
}
}
task buildDocs {
group 'Documentation'
description 'Grouping task for generating all languages in several formats'
dependsOn "includeLearningGoals", "renderDE", "renderEN"
}
task renderDE(type: RenderCurriculumTask,
constructorArgs: [curriculumFileName, versionDate, validityGerman, "DE"]) {
group 'Documentation'
description 'Builds the German curriculum as PDF and HTML file.'
doLast {
addSuffixToCurriculum("-de")
}
}
task renderEN(type: RenderCurriculumTask,
constructorArgs: [curriculumFileName, versionDate, validityEnglish, "EN"]) {
group 'Documentation'
description 'Builds the English curriculum as PDF and HTML file.'
doLast {
addSuffixToCurriculum("-en")
}
}
apply from: 'scripts/includeLearningGoals.gradle'
defaultTasks "buildDocs"