Skip to content

Commit a4170da

Browse files
author
Jeremy Jeanne
committed
Key changes:
- Update dita-ot-gradle plugin from v2.3.2 to v2.8.1 to benefits major improvment - Enable Configuration Cache for faster incremental builds - Add new verification tasks: validateDita and checkLinks
1 parent c20c513 commit a4170da

2 files changed

Lines changed: 46 additions & 39 deletions

File tree

build.gradle

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
plugins {
11-
id 'io.github.jyjeanne.dita-ot-gradle' version '2.3.2'
11+
id 'io.github.jyjeanne.dita-ot-gradle' version '2.8.1'
1212
// Removed: 'com.github.eerohele.saxon-gradle' - not Configuration Cache compatible
1313
// Replaced with: inline XsltTransformTask class below
1414
}
@@ -96,6 +96,8 @@ abstract class XsltTransformTask extends DefaultTask {
9696
}
9797

9898
import com.github.jyjeanne.DitaOtTask
99+
import com.github.jyjeanne.DitaOtValidateTask
100+
import com.github.jyjeanne.DitaLinkCheckTask
99101

100102
def getPropertyOrDefault(String name, def defaultValue) {
101103
providers.gradleProperty(name).getOrElse(defaultValue)
@@ -187,14 +189,12 @@ task autoGenerate(dependsOn: [messages, params, extensionPoints, generatePlatfor
187189
task pdf(type: DitaOtTask, dependsOn: autoGenerate) {
188190
group = 'documentation'
189191
description = 'Build PDF documentation.'
190-
// Set DITA-OT directory: pass as parameter -PditaHome or fall back to parent when run in core repo.
191192
ditaOt file(findProperty('ditaHome') ?: ditaHome)
192193
input "${projectDirPath}/userguide-book.ditamap"
193194
output outputDir
194195
transtype 'pdf'
195196
filter "${projectDirPath}/resources/pdf.ditaval"
196197

197-
// Use ditaProperties MapProperty directly for v2.3.0 compatibility
198198
ditaProperties.put('args.chapter.layout', 'BASIC')
199199
ditaProperties.put('args.gen.task.lbl', 'YES')
200200
ditaProperties.put('include.rellinks', '#default external')
@@ -205,14 +205,12 @@ task pdf(type: DitaOtTask, dependsOn: autoGenerate) {
205205
task html(type: DitaOtTask, dependsOn: autoGenerate) {
206206
group = 'documentation'
207207
description = 'Build HTML5 documentation.'
208-
// Set DITA-OT directory: pass as parameter -PditaHome or fall back to parent when run in core repo.
209208
ditaOt file(findProperty('ditaHome') ?: ditaHome)
210209
input "${projectDirPath}/userguide.ditamap"
211210
output outputDir
212211
transtype 'html5'
213212
filter "${projectDirPath}/resources/html.ditaval"
214213

215-
// Use ditaProperties MapProperty directly for v2.3.0 compatibility
216214
ditaProperties.put('args.copycss', 'yes')
217215
ditaProperties.put('args.css', 'dita-ot-doc.css')
218216
ditaProperties.put('args.csspath', 'css')
@@ -227,45 +225,26 @@ task html(type: DitaOtTask, dependsOn: autoGenerate) {
227225
task htmlhelp(type: DitaOtTask, dependsOn: autoGenerate) {
228226
group = 'documentation'
229227
description = 'Build HTML Help (.chm) documentation.'
230-
// Set DITA-OT directory: pass as parameter -PditaHome or fall back to parent when run in core repo.
231228
ditaOt file(findProperty('ditaHome') ?: ditaHome)
232229
input "${projectDirPath}/userguide.ditamap"
233230
output outputDir
234231
transtype 'htmlhelp'
235232
filter ditavalFile
236233

237-
// Use ditaProperties MapProperty directly for v2.3.0 compatibility
238234
ditaProperties.put('args.copycss', 'yes')
239235
ditaProperties.put('args.css', 'dita-ot-doc.css')
240236
ditaProperties.put('args.csspath', 'css')
241237
ditaProperties.put('args.cssroot', "${projectDirPath}/resources/")
242238
ditaProperties.put('args.gen.task.lbl', 'YES')
243-
244-
doLast {
245-
// Move .chm files using modern Gradle file operations
246-
def htmlhelpDir = file("${outputDir}/htmlhelp")
247-
if (htmlhelpDir.exists()) {
248-
copy {
249-
from htmlhelpDir
250-
into outputDir
251-
include '*.chm'
252-
}
253-
// Clean up the htmlhelp directory
254-
delete htmlhelpDir
255-
}
256-
}
257239
}
258240

259-
task cleanOutput {
241+
task cleanOutput(type: Delete) {
260242
group = 'build'
261243
description = 'Delete the output directory.'
262-
doLast {
263-
delete outputDir
264-
}
244+
delete file(outputDir)
265245
}
266246

267247
// Get git commit hash using Gradle 9 compatible Provider API
268-
// Uses providers.exec() instead of deprecated project.exec()
269248
def gitCommitHash = providers.exec {
270249
commandLine 'git', 'rev-parse', 'HEAD'
271250
ignoreExitValue = true
@@ -274,40 +253,71 @@ def gitCommitHash = providers.exec {
274253
task gitMetadata {
275254
group = 'build'
276255
description = 'Log git commit metadata.'
277-
// This task just logs the git commit for reference
278256
doLast {
279257
logger.lifecycle("Git commit: ${gitCommitHash}")
280258
}
281-
282-
// Mark outputs to help with up-to-date checking
283-
outputs.upToDateWhen { false } // Always run since git commit changes frequently
259+
outputs.upToDateWhen { false }
284260
}
285261

286262
task site(type: DitaOtTask) {
287263
group = 'documentation'
288264
description = 'Build website documentation.'
289265
dependsOn 'messages', 'params', 'extensionPoints', 'gitMetadata'
290266

291-
// Set DITA-OT directory: pass as parameter -PditaHome or fall back to parent when run in core repo.
292267
ditaOt file(findProperty('ditaHome') ?: ditaHome)
293268
input file("${projectDirPath}/site.ditamap")
294269
output getPropertyOrDefault('outputDir', layout.buildDirectory.dir("site").get().asFile.path)
295270
filter "${projectDirPath}/resources/site.ditaval"
296-
297271
transtype 'org.dita-ot.html'
298272

299273
// Evaluate the noCommitMeta flag at configuration time
300274
def includeCommitMeta = !providers.gradleProperty('noCommitMeta').map { Boolean.parseBoolean(it) }.getOrElse(false)
301275

302-
// Use ditaProperties MapProperty directly for v2.3.0 compatibility
303276
ditaProperties.put('args.gen.task.lbl', 'YES')
304277
ditaProperties.put('args.rellinks', 'noparent')
305278
if (includeCommitMeta) {
306-
// Use the git commit hash obtained at configuration time
307279
ditaProperties.put('commit', gitCommitHash)
308280
}
309281
}
310282

283+
// =============================================================================
284+
// Verification Tasks (v2.8.1 features)
285+
// =============================================================================
286+
287+
task validateDita(type: DitaOtValidateTask) {
288+
group = 'verification'
289+
description = 'Validate DITA content without full transformation.'
290+
ditaOtDir = file(findProperty('ditaHome') ?: ditaHome)
291+
inputFiles = files(
292+
"${projectDirPath}/userguide.ditamap",
293+
"${projectDirPath}/userguide-book.ditamap",
294+
"${projectDirPath}/site.ditamap"
295+
)
296+
strictMode = false
297+
failOnError = true
298+
}
299+
300+
task checkLinks(type: DitaLinkCheckTask) {
301+
group = 'verification'
302+
description = 'Check for broken internal and external links.'
303+
inputFiles = files(
304+
"${projectDirPath}/userguide.ditamap",
305+
"${projectDirPath}/userguide-book.ditamap"
306+
)
307+
checkExternal = false // Set to true to also check external URLs
308+
failOnBroken = true
309+
recursive = true
310+
}
311+
312+
task verify(dependsOn: [validateDita, checkLinks]) {
313+
group = 'verification'
314+
description = 'Run all verification tasks (validate DITA and check links).'
315+
}
316+
317+
// =============================================================================
318+
// Aggregate Tasks
319+
// =============================================================================
320+
311321
task all(dependsOn: [pdf, html, htmlhelp]) {
312322
group = 'documentation'
313323
description = 'Build all documentation formats (PDF, HTML, HTMLHelp).'

gradle.properties

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# Fix Java memory errors with Gradle 5.2
22
org.gradle.jvmargs = -Xmx1024m
33

4-
# Gradle 8 features for better performance and caching
5-
# ↓ Not supported by eerohele/dita-ot-gradle ↓
6-
# org.gradle.configuration-cache=true
7-
# org.gradle.configuration-cache.problems=warn
8-
# ↑ Not supported by eerohele/dita-ot-gradle ↑
4+
# Gradle 9 features for better performance and caching
5+
org.gradle.configuration-cache=true
96
org.gradle.parallel=true
107
org.gradle.caching=true

0 commit comments

Comments
 (0)