Skip to content

Commit ac79e97

Browse files
eeroheleinfotexture
authored andcommitted
Replace Ant build with Gradle build (#178)
Signed-off-by: Eero Helenius <eero.helenius@kapsi.fi>
1 parent bc1b69c commit ac79e97

File tree

4 files changed

+128
-285
lines changed

4 files changed

+128
-285
lines changed

.travis/publish.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export SITE_DIR=$PWD/dita-ot.github.io
1010
# Remove target output directory before generating new output
1111
rm -rf "$SITE_DIR/dev"
1212
# Re-create /dev folder & generate site output there
13-
./gradlew -b site.gradle -Ddita.home=$DITA_HOME -Doutput.dir=$SITE_DIR/dev -PditaHomeSrc=$DITA_OT_DEV --info --stacktrace --no-daemon
13+
./gradlew site -PditaHome=$DITA_HOME -PoutputDir=$SITE_DIR/dev -PditaHomeSrc=$DITA_OT_DEV --info --stacktrace --no-daemon
1414
#else
15-
# ./gradlew -Ddita.home=$DITA_HOME html --info --stacktrace --no-daemon
15+
# ./gradlew -PditaHome=$DITA_HOME html --info --stacktrace --no-daemon
1616
#fi

build.gradle

Lines changed: 126 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,150 @@
11
plugins {
2-
id 'com.github.eerohele.dita-ot-gradle' version '0.4.2'
2+
id 'com.github.eerohele.dita-ot-gradle' version '0.4.3'
3+
id 'com.github.eerohele.saxon-gradle' version '0.3.0'
34
}
45

5-
ditaOt.dir System.getProperty('dita.home', '../')
6+
import com.github.eerohele.DitaOtTask
7+
import com.github.eerohele.SaxonXsltTask
68

7-
import com.github.eerohele.AntBuilderAssistant
8-
def antBuilder = AntBuilderAssistant.getAntBuilder(project)
9+
def getPropertyOrDefault(String name, def defaultValue) {
10+
hasProperty(name) ? findProperty(name) : defaultValue
11+
}
912

10-
task pdf {
11-
doLast {
12-
antBuilder.execute {
13-
ant(antfile: 'build.xml', target: 'pdf')
13+
String ditaHome = getPropertyOrDefault('ditaHome', projectDir.getParent())
14+
String ditaHomeSrc = getPropertyOrDefault('ditaHomeSrc', ditaHome)
15+
String configDir = "${ditaHomeSrc}/config"
16+
String ditavalFile = "${projectDir}/platform.ditaval"
17+
Boolean toolkitBuild = file("${projectDir}/../lib/dost.jar").exists()
18+
String samplesDir = toolkitBuild ? "${ditaHome}/docsrc/samples" : "${projectDir}/samples"
19+
String outputDir = getPropertyOrDefault('outputDir', toolkitBuild ? "${ditaHome}/doc" : "${projectDir}/out")
20+
21+
String toURI(String path) {
22+
file(path).toURI().toString()
23+
}
24+
25+
ditaOt.dir ditaHome
26+
27+
task messages(type: SaxonXsltTask) {
28+
input "${configDir}/messages.xml"
29+
output "${projectDir}/user-guide/DITA-messages.xml"
30+
stylesheet "${projectDir}/resources/messages.xsl"
31+
}
32+
33+
task params(type: SaxonXsltTask) {
34+
input "${configDir}/plugins.xml"
35+
output "${projectDir}/parameters/all-parameters.dita"
36+
stylesheet "${projectDir}/resources/params.xsl"
37+
parameters('output-dir.url': toURI('parameters'))
38+
outputs.dir "${projectDir}/parameters"
39+
}
40+
41+
task extensionPoints(type: SaxonXsltTask) {
42+
input "${configDir}/plugins.xml"
43+
output "${projectDir}/extension-points/all-extension-points.dita"
44+
stylesheet "${projectDir}/resources/extension-points.xsl"
45+
parameters('output-dir.url': toURI('extension-points'))
46+
outputs.dir "${projectDir}/extension-points"
47+
}
48+
49+
task generatePlatformFilter {
50+
ant.condition(property: 'platform', value: 'windows') {
51+
os(family: 'windows')
52+
}
53+
54+
ant.condition(property: 'platform', value: 'osx' ) {
55+
os(family: 'mac')
56+
}
57+
58+
ant.condition(property: 'platform', value: 'unix' ) {
59+
os(family: 'unix')
60+
}
61+
62+
ant.echoxml(file: ditavalFile) {
63+
val {
64+
prop(action: 'include', att: 'platform', val: platform)
65+
prop(action: 'exclude', att: 'platform')
66+
}
1467
}
15-
}
1668
}
1769

18-
task html {
19-
doLast {
20-
antBuilder.execute {
21-
ant(antfile: 'build.xml', target: 'html')
70+
task autoGenerate(dependsOn: [messages, params, extensionPoints, generatePlatformFilter]) {
71+
description 'Run tasks that generate content from resource files and the build environment.'
72+
}
73+
74+
task pdf(type: DitaOtTask, dependsOn: autoGenerate) {
75+
input "${projectDir}/userguide-book.ditamap"
76+
output outputDir
77+
transtype 'pdf'
78+
79+
properties {
80+
property(file: "${projectDir}/samples/properties/docs-build-pdf.properties")
2281
}
23-
}
2482
}
2583

26-
task htmlhelp {
27-
doLast {
28-
antBuilder.execute {
29-
ant(antfile: 'build.xml', target: 'htmlhelp')
84+
task html(type: DitaOtTask, dependsOn: autoGenerate) {
85+
input "${projectDir}/userguide.ditamap"
86+
output outputDir
87+
transtype 'html5'
88+
89+
properties {
90+
property(file: "${projectDir}/samples/properties/docs-build-html5.properties")
91+
}
92+
}
93+
94+
task htmlhelp(type: DitaOtTask, dependsOn: autoGenerate) {
95+
input "${projectDir}/userguide.ditamap"
96+
output outputDir
97+
transtype 'htmlhelp'
98+
filter ditavalFile
99+
100+
properties {
101+
property(file: "${projectDir}/samples/properties/docs-build-htmlhelp.properties")
102+
}
103+
104+
doLast {
105+
ant.move(todir: outputDir, failonerror: 'no') {
106+
fileset(dir: "${outputDir}/htmlhelp", includes: '*.chm')
107+
}
108+
109+
ant.delete(dir: "${outputDir}/htmlhelp")
30110
}
31-
}
32111
}
33112

34113
task cleanUp {
114+
doLast {
115+
ant.delete(dir: outputDir)
116+
}
117+
}
118+
119+
def commit = new ByteArrayOutputStream()
120+
121+
task gitMetadata {
35122
doLast {
36-
antBuilder.execute {
37-
ant(antfile: 'build.xml', target: 'clean')
123+
exec {
124+
workingDir = projectDir
125+
commandLine 'git'
126+
args = ['rev-parse', 'HEAD']
127+
standardOutput = commit
38128
}
39129
}
40130
}
41131

42-
task all(dependsOn: [pdf, html, htmlhelp])
132+
task site(type: DitaOtTask) {
133+
dependsOn 'messages', 'params', 'extensionPoints', 'gitMetadata'
134+
135+
input file("${projectDir}/site.ditamap")
136+
output getPropertyOrDefault('outputDir', "${buildDir}/site")
43137

138+
transtype 'org.dita-ot.html'
139+
140+
properties {
141+
property(name: 'args.gen.task.lbl', value: 'YES')
142+
property(name: 'args.rellinks', value: 'noparent')
143+
property(name: 'commit', value: commit)
144+
}
145+
}
146+
147+
task all(dependsOn: [pdf, html, htmlhelp])
44148
task dist(dependsOn: [pdf, html])
45149

46150
defaultTasks 'dist'

build.xml

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)