-
Notifications
You must be signed in to change notification settings - Fork 97
/
build.gradle
192 lines (157 loc) · 5.87 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
plugins {
id 'com.github.eerohele.dita-ot-gradle' version '0.7.1'
id 'com.github.eerohele.saxon-gradle' version '0.9.0-beta4'
}
// Specify Saxon version per https://github.com/eerohele/saxon-gradle/blob/master/README.md
repositories {
mavenCentral()
}
configurations {
saxon
}
dependencies {
// Use Saxon-HE 10.6 like DITA-OT, instead of the version that comes with `saxon-gradle`
saxon 'net.sf.saxon:Saxon-HE:10.6'
}
import com.github.eerohele.DitaOtTask
import com.github.eerohele.SaxonXsltTask
def getPropertyOrDefault(String name, def defaultValue) {
hasProperty(name) ? findProperty(name) : defaultValue
}
String ditaHome = getPropertyOrDefault('ditaHome', projectDir.getParent())
String ditaHomeSrc = getPropertyOrDefault('ditaHomeSrc', ditaHome)
String configDir = "${ditaHomeSrc}/config"
String ditavalFile = "${projectDir}/platform.ditaval"
Boolean toolkitBuild = file("${projectDir}/../lib/dost.jar").exists()
String samplesDir = toolkitBuild ? "${ditaHome}/docsrc/samples" : "${projectDir}/samples"
String outputDir = getPropertyOrDefault('outputDir', toolkitBuild ? "${ditaHome}/doc" : "${projectDir}/out")
String toURI(String path) {
file(path).toURI().toString()
}
ditaOt.dir ditaHome
task messages(type: SaxonXsltTask) {
input "${configDir}/messages.xml"
output "${projectDir}/topics/error-messages.xml"
stylesheet "${projectDir}/resources/messages.xsl"
}
task params(type: SaxonXsltTask) {
input "${configDir}/plugins.xml"
output "${projectDir}/parameters/all-parameters.dita"
stylesheet "${projectDir}/resources/params.xsl"
parameters('output-dir.url': toURI('parameters'))
outputs.dir "${projectDir}/parameters"
}
task extensionPoints(type: SaxonXsltTask) {
input "${configDir}/plugins.xml"
output "${projectDir}/extension-points/all-extension-points.dita"
stylesheet "${projectDir}/resources/extension-points.xsl"
parameters('output-dir.url': toURI('extension-points'))
outputs.dir "${projectDir}/extension-points"
}
task generatePlatformFilter {
ant.condition(property: 'platform', value: 'windows') {
os(family: 'windows')
}
ant.condition(property: 'platform', value: 'mac' ) {
os(family: 'mac')
}
ant.condition(property: 'platform', value: 'unix' ) {
os(family: 'unix')
}
ant.echoxml(file: ditavalFile) {
val {
prop(action: 'include', att: 'platform', val: platform)
prop(action: 'exclude', att: 'platform')
}
}
}
task generatePropertiesTemplate(type: SaxonXsltTask) {
input "${configDir}/plugins.xml"
output "${samplesDir}/properties/template.properties"
stylesheet "${projectDir}/resources/properties-file.xsl"
}
task autoGenerate(dependsOn: [messages, params, extensionPoints, generatePlatformFilter, generatePropertiesTemplate]) {
description 'Run tasks that generate content from resource files and the build environment.'
}
task pdf(type: DitaOtTask, dependsOn: autoGenerate) {
input "${projectDir}/userguide-book.ditamap"
output outputDir
transtype 'pdf'
filter "${projectDir}/resources/pdf.ditaval"
properties {
property(name: 'args.chapter.layout', value: 'BASIC')
property(name: 'args.gen.task.lbl', value: 'YES')
property(name: 'include.rellinks', value: '#default external')
property(name: 'outputFile.base', value: 'userguide')
property(name: 'theme', value: "${projectDir}/samples/themes/dita-ot-docs-theme.yaml")
}
}
task html(type: DitaOtTask, dependsOn: autoGenerate) {
input "${projectDir}/userguide.ditamap"
output outputDir
transtype 'html5'
filter "${projectDir}/resources/html.ditaval"
properties {
property(name: 'args.copycss', value: 'yes')
property(name: 'args.css', value: 'dita-ot-doc.css')
property(name: 'args.csspath', value: 'css')
property(name: 'args.cssroot', value: "${projectDir}/resources/")
property(name: 'args.gen.task.lbl', value: 'YES')
property(name: 'args.hdr', value: "${projectDir}/resources/header.xml")
property(name: 'args.rellinks', value: 'noparent')
property(name: 'html5.toc.generate', value: 'no')
property(name: 'nav-toc', value: 'partial')
}
}
task htmlhelp(type: DitaOtTask, dependsOn: autoGenerate) {
input "${projectDir}/userguide.ditamap"
output outputDir
transtype 'htmlhelp'
filter ditavalFile
properties {
property(name: 'args.copycss', value: 'yes')
property(name: 'args.css', value: 'dita-ot-doc.css')
property(name: 'args.csspath', value: 'css')
property(name: 'args.cssroot', value: "${projectDir}/resources/")
property(name: 'args.gen.task.lbl', value: 'YES')
}
doLast {
ant.move(todir: outputDir, failonerror: 'no') {
fileset(dir: "${outputDir}/htmlhelp", includes: '*.chm')
}
ant.delete(dir: "${outputDir}/htmlhelp")
}
}
task cleanUp {
doLast {
ant.delete(dir: outputDir)
}
}
def commit = new ByteArrayOutputStream()
task gitMetadata {
doLast {
exec {
workingDir = projectDir
commandLine 'git'
args = ['rev-parse', 'HEAD']
standardOutput = commit
}
}
}
task site(type: DitaOtTask) {
dependsOn 'messages', 'params', 'extensionPoints', 'gitMetadata'
input file("${projectDir}/site.ditamap")
output getPropertyOrDefault('outputDir', "${buildDir}/site")
filter "${projectDir}/resources/site.ditaval"
transtype 'org.dita-ot.html'
properties {
property(name: 'args.gen.task.lbl', value: 'YES')
property(name: 'args.rellinks', value: 'noparent')
if (!(project.hasProperty('noCommitMeta') && Boolean.parseBoolean(project.property('noCommitMeta')))) {
property(name: 'commit', value: commit)
}
}
}
task all(dependsOn: [pdf, html, htmlhelp])
task dist(dependsOn: [pdf, html])
defaultTasks 'dist'