-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
87 lines (66 loc) · 2.41 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
description = 'copy FAQ files over from arc42-in-practice project'
defaultTasks 'info'
File faqSrcDir = file('../arc42-in-practice/manuscript/07_faq/')
File imageSrcDir = file ('../arc42-in-practice/manuscript/images/faq')
File faqTargetDir = file('manuscript/faq_DONT_EDIT_HERE')
File imageTargetDir = file('manuscript/images/faq')
task copyFAQ(dependsOn: "inPracticeDirsExist") << {
description "copy all FAQ files from arc42-in-Practice project"
println "Copying and filtering FAQ markdown files from ${faqSrcDir}"
copy {
from faqSrcDir
into faqTargetDir
include '**/*.md'
filter { String line ->
line.contains('VII.') ? line.replaceAll("VII.", "") : line
}
}
println "Copying and filtering image files from ${imageSrcDir}"
copy {
from imageSrcDir
into imageTargetDir
include '**/*.png'
include '**/*.jpg'
}
}
task clean(type: Delete) {
println "Deleting target directories $imageTargetDir and $faqTargetDir"
delete imageTargetDir, faqTargetDir
followSymlinks = true
}
task inPracticeDirsExist << {
// if directories in "arc42-in-practice" don't exist, abort...
print "\nChecking if arc42-in-practice directories exist..."
if (!imageSrcDir.exists()) {
throw new GradleException("Exception:\nRequired directory ${imageSrcDir.absolutePath} not found.\n")
}
print "..."
if (!faqSrcDir.exists()) {
throw new GradleException("Exception:\nRequired directory ${faqSrcDir.absolutePath} not found.\n")
}
println "... successful.\n"
}
task listImages() << {
FileCollection collection
println "\nContents of $imageSrcDir.absolutePath"
collection = files{ imageSrcDir.listFiles() }
collection.collect { relativePath(it) }.sort().each { println it }
println "\nContents of $imageTargetDir.absolutePath"
collection = files{ imageTargetDir.listFiles() }
collection.collect { relativePath(it) }.sort().each { println it }
}
task info << {
println """\n
*** =============================== ***
*** This is the arc42-FAQ copy task ***
*** =============================== ***
It will do the following stuff:
1.) copy all markdown files containing FAQs.
2.) removing heading and section numbers, which are explicitely included
in the arc42-in-practice book.
3.) copy all images or diagrams required.
To do this, it requires the git repositories for 'arc42-in-practice'
and 'arc42-FAQ' checked out next to each other.
You can execute it by 'gradle copyFAQ'
"""
}