This repository was archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
executable file
·128 lines (111 loc) · 3.53 KB
/
Copy pathbuild.gradle
File metadata and controls
executable file
·128 lines (111 loc) · 3.53 KB
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
import static groovy.io.FileType.*
buildscript {
dependencies {
classpath 'org.asciidoctor:asciidoctorj-diagram:1.5.4.1'
}
}
//tag::jbakeplugin[]
plugins {
id 'org.jbake.site' version '5.0.0'
id "org.aim42.htmlSanityCheck" version "1.1.3"
}
//end::jbakeplugin[]
repositories {
mavenCentral()
jcenter()
}
//tag::jbakeconfig[]
jbake {
version = '2.6.4'
srcDirName = 'src/main/jbake'
destDirName = 'docs/html5/site'
configuration['asciidoctor.option.requires'] = "asciidoctor-diagram"
}
bakePreview {
port = '8820'
}
//end::jbakeconfig[]
/**
//configure docToolchain to use the main project's config
project('docToolchain') {
if (project.hasProperty('docDir')) {
docDir = '../.'
mainConfigFile = 'Config.groovy'
} else {
println "="*80
println " please initialize the docToolchain submodule"
println " by executing git submodule update -i"
println "="*80
}
}
**/
//for 'clean'-task
apply plugin:'java'
htmlSanityCheck {
sourceDir = new File( "$buildDir/docs/html5/site" )
// where to put results of sanityChecks...
checkingResultsDir = new File( "$buildDir/report/htmlchecks" )
// fail build on errors?
failOnErrors = false
}
task submodulesUpdate(type:Exec) {
description 'Updates git submodules'
commandLine 'git', 'submodule', 'update', "--init", "--recursive"
doLast { println "git submodule update"}
}
task copyImages1(type:Copy) {
from("$projectDir/references/dukecon/src/main/asciidoc/images") {}
into("$buildDir/docs/html5/site/images")
doLast { println "images copied"}
}
task copyReports(type:Copy) {
from("$buildDir/report")
into("$buildDir/docs/html5/site/testreports/")
println '$buildDir/docs/html5/site/testreports/'
}
task copyResources(
dependsOn: [copyImages1]
) {
doLast { println "resources copied"}
}
task buildDocs(
dependsOn: [submodulesUpdate, copyResources, bake, htmlSanityCheck, copyReports]
) {
doLast {
}
}
task prependFilename(
description: 'crawls through all AsciiDoc files and prepends the name of the current file',
group: 'docToolchain helper',
) {
doLast {
File sourceFolder = new File(projectDir.canonicalPath,"references")
println("sourceFolder: " + sourceFolder.canonicalPath)
sourceFolder.traverse(type: FILES) { file ->
if (file.name ==~ '^.*(ad|adoc|asciidoc)$') {
if (file.name.split('[.]')[0] in ["feedback", "_feedback", "config", "_config"]) {
println "skipped "+file.name
} else {
def text = file.getText('utf-8')
def name = file.canonicalPath - sourceFolder.canonicalPath
name = name.replace("\\", "/").replaceAll("^/", "")
if (text.contains(":filename:")) {
text = text.replaceAll(":filename:.*", ":filename: $name")
println "updated "+name
} else {
text = ":filename: $name\n" + text
println "added "+name
}
file.write(text,'utf-8')
}
}
}
}
}
bake.shouldRunAfter copyResources
htmlSanityCheck.shouldRunAfter bake
copyReports.shouldRunAfter htmlSanityCheck
copyImages1.shouldRunAfter submodulesUpdate
copyResources.shouldRunAfter submodulesUpdate
bake.shouldRunAfter submodulesUpdate
defaultTasks 'copyResources', 'bake', 'htmlSanityCheck', 'copyReports', 'bakePreview'