forked from dita-ot/dita-ot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
510 lines (463 loc) · 17.9 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
/*
* This file is part of the DITA Open Toolkit project.
*
* Copyright 2015 Jarno Elovirta
*
* See the accompanying LICENSE file for applicable license.
*/
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
group = 'org.dita-ot'
archivesBaseName = 'dost'
/** Semver version number */
version = '4.3.0-SNAPSHOT'
description = """DITA Open Toolkit"""
sourceCompatibility = 17
targetCompatibility = 17
repositories {
mavenCentral()
maven {
url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/"
}
}
dependencies {
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'xerces', name: 'xercesImpl', version:'2.12.2'
implementation group: 'xml-apis', name: 'xml-apis', version:'1.4.01'
implementation group: 'xml-resolver', name: 'xml-resolver', version:'1.2'
implementation group: 'net.sf.saxon', name: 'Saxon-HE', version: '12.4'
implementation group: 'org.xmlresolver', name: 'xmlresolver', version: '5.2.3'
implementation group: 'com.ibm.icu', name: 'icu4j', version:'74.2'
implementation group: 'org.apache.ant', name: 'ant', version:'1.10.14'
implementation group: 'org.apache.ant', name: 'ant-launcher', version:'1.10.14'
implementation(group: 'com.google.guava', name: 'guava', version: '32.1.1-jre') {
exclude group: 'org.checkerframework', module: 'checker-qual'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
exclude group: 'com.google.guava', module: 'failureaccess'
exclude group: 'com.google.guava', module: 'listenablefuture'
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
exclude group: 'com.google.j2objc', module: 'j2objc-annotations'
}
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.12'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.16.1'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.1'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.16.1'
implementation group: 'org.relaxng', name: 'jing', version: '20220510'
implementation group: 'org.apache.ant', name: 'ant-apache-resolver', version:'1.10.14'
testImplementation group: 'nu.validator.htmlparser', name: 'htmlparser', version:'1.4'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.10.2'
testImplementation group: 'org.xmlunit', name: 'xmlunit-core', version: '2.9.1'
}
jar {
archiveFileName = "${project.name}.jar"
exclude "catalog.xml"
}
processResources {
filter ReplaceTokens, tokens: [
'version': project.version,
'release': "${project.version.split('\\.').toList().subList(0, 2).join('.').toString()}".toString()
]
}
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = 'javadoc'
}
artifacts {
archives jar, javadocJar, sourcesJar
}
test {
useJUnitPlatform {
filter {
includeTestsMatching "*Test"
excludeTestsMatching "IntegrationTest*"
excludeTestsMatching "EndToEndTest*"
}
}
}
test.maxParallelForks = 4
// Integration test
def integrationTestSystemProperties = [
temp_dir : "${buildDir}/tmp/integrationTest",
dita_dir : "${projectDir}/src/main",
basedir : "${projectDir}/src/test"
]
if (System.getProperty("test") != null) {
integrationTestSystemProperties["test"] = System.getProperty("test")
}
if (System.getProperty("log_level") != null) {
integrationTestSystemProperties["log_level"] = System.getProperty("log_level")
}
tasks.register('integrationTest', Test) {
dependsOn 'buildLocal'
minHeapSize = "128m"
maxHeapSize = "1024m"
systemProperties = integrationTestSystemProperties
useJUnitPlatform {
filter {
includeTestsMatching 'IntegrationTest*'
}
}
}
tasks.named('check') {
dependsOn('integrationTest')
}
// End to end test
dependencies {
testImplementation project(':htmlhelp')
testImplementation project(':fo')
testImplementation project(':fop')
}
def e2eTestSystemProperties = [
temp_dir : "${buildDir}/tmp/e2eTest",
dita_dir : "${projectDir}/src/main",
basedir : "${projectDir}/src/test"
]
if (System.getProperty("log_level") != null) {
integrationTestSystemProperties["log_level"] = System.getProperty("log_level")
}
tasks.register('e2eTest', Test) {
dependsOn 'buildLocal'
minHeapSize = "128m"
maxHeapSize = "1024m"
maxParallelForks = 4
systemProperties = e2eTestSystemProperties
useJUnitPlatform {
filter {
includeTestsMatching 'EndToEndTest*'
}
}
}
tasks.named('check') {
dependsOn('e2eTest')
}
// Install
defaultTasks 'buildLocal'
clean {
delete "src/main/lib/"
delete "src/main/plugins/org.dita.htmlhelp/lib/"
delete "src/main/plugins/org.dita.pdf2/lib/"
delete "src/main/plugins/org.dita.pdf2.fop/lib/"
}
task copyInstall(type: Copy) {
from (jar)
from (configurations.runtimeClasspath.allArtifacts.files)
from (configurations.runtimeClasspath) {
rename "ant-launcher(-\\d+(\\.\\d+(\\.\\d+)?)?)\\.jar", "ant-launcher.jar"
rename "ant(-\\d+(\\.\\d+(\\.\\d+)?)?)\\.jar", "ant.jar"
}
destinationDir = file("src/main/lib")
}
task buildLocal(type: JavaExec, dependsOn: [copyInstall, ":fo:copyInstall", ":fop:copyInstall", ":htmlhelp:copyInstall", ":html5:compileSass"]) {
description "Build archives and install all plugins with dependencies"
mainClass = "org.apache.tools.ant.launch.Launcher"
classpath = sourceSets.main.runtimeClasspath + files("${projectDir}/src/main", "${projectDir}/src/main/config")
workingDir file("${projectDir}/src/main")
args "-f"
args file("${projectDir}/src/main/integrator.xml")
}
// Distribution
ext.distTempDir = file("${buildDir}/tmp/dist")
/** When patch is "0", only use major and minor versions, e.g. 1.2 instead of 1.2.0 */
def cleanVersion = project.version.split('\\.').toList()[2] == "0" ?
project.version.split('\\.').toList().subList(0, 2).join('.').toString() :
project.version
def distVersion = project.hasProperty("commit") && (!project.hasProperty("tag") || tag.empty) ?
"${project.version}@${commit.substring(0, 7)}" :
"${cleanVersion}"
def distFileName = (project.hasProperty("tag") && tag.empty) ?
"develop" :
"${cleanVersion}"
def bundled = [
"eclipsehelp": "https://github.com/dita-ot/org.dita.eclipsehelp/releases/download/3.4/org.dita.eclipsehelp-3.4.0.zip",
"markdown": "https://github.com/jelovirt/org.lwdita/releases/download/5.7.0/org.lwdita-5.7.0.zip",
"normalize": "https://github.com/dita-ot/org.dita.normalize/archive/refs/tags/2.0.zip",
"dita11": "https://github.com/dita-ot/org.dita.specialization.dita11/archive/1.1.1.zip",
"dita12": "https://github.com/dita-ot/org.oasis-open.dita.v1_2/archive/1.2.1.zip",
"dita20": "https://github.com/dita-ot/dita/releases/download/2.0.0-20240115/org.oasis-open.dita.v2_0.zip",
"dita20-techcomm": "https://github.com/dita-ot/dita-techcomm/releases/download/2.0.0-20240122/org.oasis-open.dita.techcomm.v2_0.zip",
"xdita": "https://github.com/oasis-tcs/dita-lwdita/releases/download/v0.3.0.2/org.oasis-open.xdita.v0_3_2.zip",
"index": "https://github.com/dita-ot/org.dita.index/releases/download/1.0.0/org.dita.index-1.0.0.zip",
"axf": "https://github.com/dita-ot/org.dita.pdf2.axf/releases/download/3.6.1/org.dita.pdf2.axf-3.6.1.zip",
"xep": "https://github.com/dita-ot/org.dita.pdf2.xep/releases/download/3.6.3/org.dita.pdf2.xep-3.6.3.zip",
"theme": "https://github.com/jelovirt/pdf-generator/releases/download/0.7.2/com.elovirta.pdf-0.7.2.zip",
]
apply from: 'gradle/dist.gradle'
task cleanDistTemp(type: Delete) {
delete distTempDir
}
task initDist(dependsOn: [jar, cleanDistTemp]) {
doLast {
distTempDir.mkdirs()
println "distVersion: ${distVersion}"
println "distFileName: ${distFileName}"
}
}
task copyDistTemp(type: Copy, dependsOn: initDist) {
from (jar) {
into "lib"
}
from (configurations.runtimeClasspath.allArtifacts.files) {
into "lib"
}
from (configurations.runtimeClasspath) {
into "lib"
rename "ant-launcher(-\\d+(\\.\\d+(\\.\\d+)?)?)\\.jar", "ant-launcher.jar"
rename "ant(-\\d+(\\.\\d+(\\.\\d+)?)?)\\.jar", "ant.jar"
}
from (".") {
include "LICENSE"
}
from ("src/main") {
include "plugins/*/plugin.xml"
expand(
version: project.version
)
}
from ("src/main") {
exclude ".gradle"
exclude "plugins/**/build.gradle"
exclude "plugins/**/settings.gradle"
exclude "plugins/**/.gradle"
exclude ".*"
exclude "local.properties"
include "*.*"
include "bin/dita"
include "bin/dita.bat"
exclude "docsrc/.*"
exclude "docsrc/*.md"
exclude "docsrc/*.xpr"
exclude "docsrc/package*.json"
include "docsrc/**"
exclude "plugins/*/plugin.xml"
include "plugins/org.dita.base/**"
include "plugins/org.dita.html5/**"
exclude "plugins/org.dita.html5/build"
exclude "plugins/org.dita.html5/.sass-cache"
include "plugins/org.dita.htmlhelp/**"
include "plugins/org.dita.pdf2.axf/**"
include "plugins/org.dita.pdf2.fop/**"
exclude "plugins/org.dita.pdf2.fop/build"
include "plugins/org.dita.pdf2/**"
exclude "plugins/org.dita.pdf2/src/**"
exclude "plugins/org.dita.pdf2/build"
exclude "plugins/org.dita.pdf2/bin/**"
include "plugins/org.dita.specialization.dita11/**"
include "plugins/org.dita.xhtml/**"
include "plugins/org.oasis-open.dita.v1_2/**"
include "plugins/org.oasis-open.dita.v1_3/**"
exclude "temp"
include "config/**"
include "resources/catalog.xml"
include "resources/plugin.rnc"
include "resources/project.rnc"
// legacy build scripts
include "startcmd.*"
include "bin/ant"
include "bin/ant.*"
}
destinationDir = distTempDir
}
copyDistTemp.outputs.dir distTempDir
task integrateDistTemp(type: JavaExec, dependsOn: [copyDistTemp, ":fo:copyDistTemp", ":fop:copyDistTemp", ":htmlhelp:copyDistTemp"]) {
mainClass = "org.apache.tools.ant.launch.Launcher"
classpath = sourceSets.main.runtimeClasspath + files("${distTempDir}", "${projectDir}/src/main/config")
workingDir distTempDir
args "-f"
args file("${distTempDir}/integrator.xml")
}
task integrateDistPlugins() {
dependsOn bundled.collect{ name, url ->
return tasks.create("integrateDist${name}", JavaExec) {
dependsOn(integrateDistTemp)
mainClass = "org.apache.tools.ant.launch.Launcher"
classpath = sourceSets.main.runtimeClasspath + files("${distTempDir}", "${projectDir}/src/main/config")
workingDir distTempDir
args "-f"
args file("${distTempDir}/integrator.xml")
args "install"
args "-Dplugin.file=${url}"
}.name
}
}
integrateDistPlugins.mustRunAfter integrateDistTemp
task generateDocs(type: Exec, dependsOn: integrateDistTemp) {
workingDir = file("${distTempDir}/docsrc")
commandLine = Os.isFamily(Os.FAMILY_WINDOWS) ? file("${distTempDir}/docsrc/gradlew.bat") : file("${distTempDir}/docsrc/gradlew")
args = ["--no-daemon", "dist"]
}
generateDocs.mustRunAfter integrateDistPlugins
generateDocs.onlyIf { skipDocs() }
task cleanGenerateDocs(type: Delete) {
delete "${distTempDir}/temp"
delete "${distTempDir}/docsrc/.gradle"
delete "${distTempDir}/docsrc/build"
delete "${distTempDir}/docsrc/node_modules"
delete "${distTempDir}/docsrc/out"
delete "${distTempDir}/docsrc/platform.ditaval"
delete "${distTempDir}/docsrc/temp"
}
cleanGenerateDocs.mustRunAfter generateDocs
cleanGenerateDocs.onlyIf { skipDocs() }
def skipDocs() {
!(project.hasProperty('skipGenerateDocs') && Boolean.parseBoolean(project.property('skipGenerateDocs')))
}
task generateJavadocs(type: Javadoc) {
include "**/org/dita/dost/*.*"
include "**/org/dita/dost/exception/DITAOTException.*"
include "**/org/dita/dost/util/Configuration.*"
options.addStringOption("public")
title = "${project.description} ${project.version}"
destinationDir = file("${distTempDir}/doc/api")
}
generateJavadocs.onlyIf { skipDocs() }
def plugins = [
"org.dita.html5",
"org.dita.htmlhelp",
"org.dita.pdf2",
"org.dita.pdf2.fop",
"org.dita.xhtml",
]
task distPlugins() {
dependsOn plugins.collect{ name ->
def taskName = "distPlugin${name.split("\\.").collect{token -> return token.capitalize()}.join("")}"
return tasks.create(taskName, Zip) {
dependsOn(integrateDistTemp)
from ("${distTempDir}/plugins/${name}") {
exclude "build"
exclude "src"
exclude "out"
}
archiveFileName = "${name}-${project.version}.zip"
}.name
}
}
distPlugins.mustRunAfter integrateDistPlugins
task distPluginChecksums() {
doLast {
ant.checksum(algorithm: "SHA-256", fileext: ".sha256") {
fileset(dir: "${buildDir}/distributions") {
include(name: '*.zip')
}
}
}
}
distPluginChecksums.mustRunAfter distPlugins
generateNotices.mustRunAfter distPlugins
task dist(type: Zip, dependsOn: [jar, integrateDistTemp, integrateDistPlugins, distPlugins, distPluginChecksums, generateNotices, generateDocs, cleanGenerateDocs, generateJavadocs]) {
into("dita-ot-${distVersion}") {
from (distTempDir) {
exclude "bin/dita"
exclude "bin/dita.bat"
// legacy build scripts
exclude "startcmd.*"
exclude "bin/ant"
exclude "bin/ant.*"
}
from (distTempDir) {
fileMode = 0755
include "bin/dita"
include "bin/dita.bat"
// legacy build scripts
include "startcmd.*"
include "bin/ant"
include "bin/ant.*"
}
}
archiveFileName = "dita-ot-${distFileName}.zip"
}
test {
inputs.files (
'src/test/xsl/common/dita-utilities.xspec',
'src/test/xsl/common/uri-utils.xspec',
'src/test/xsl/plugins/org.dita.html5/xsl/functions.xspec',
'src/test/xsl/plugins/org.dita.html5/xsl/object.xspec',
'src/test/xsl/plugins/org.dita.html5/xsl/simpletable.xspec',
'src/test/xsl/plugins/org.dita.html5/xsl/tables.xspec',
'src/test/xsl/plugins/org.dita.pdf2/xsl/fo/simpletable.xspec',
'src/test/xsl/plugins/org.dita.pdf2/xsl/fo/topic.xspec',
'src/test/xsl/preprocess/conrefImpl.xspec',
'src/test/xsl/preprocess/maplinkImpl.xspec'
)
}
// Repository deployment
def getRepositoryUsername() {
return project.hasProperty('ossrhUsername') ?
project.property('ossrhUsername') :
System.env.containsKey('OSSRH_USERNAME') ?
System.env['OSSRH_USERNAME'] :
""
}
def getRepositoryPassword() {
return project.hasProperty('ossrhPassword') ?
project.property('ossrhPassword') :
System.env.containsKey('OSSRH_PASSWORD') ?
System.env['OSSRH_PASSWORD'] :
""
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
afterEvaluate {
pom {
name = 'DITA Open Toolkit'
description = 'DITA-OT base library'
url = 'https://www.dita-ot.org/'
scm {
connection = 'scm:git:https://github.com/dita-ot/dita-ot.git'
developerConnection = 'scm:git:[email protected]:dita-ot/dita-ot.git'
url = 'https://github.com/dita-ot/dita-ot/'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'robander'
name = 'Robert D Anderson'
email = '[email protected]'
}
developer {
id = 'jelovirt'
name = 'Jarno Elovirta'
email = '[email protected]'
}
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username getRepositoryUsername()
password getRepositoryPassword()
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}