@@ -30,6 +30,23 @@ class JavaDocUtils {
30
30
createModulesPage(name, version, outputDir)
31
31
}
32
32
33
+ private static def aggregateJavaDocRec (File current , File output , String ... ignoreDirs ) {
34
+ if (! current. isDirectory()) return
35
+
36
+ def files = current. listFiles()
37
+ if (files == null ) return
38
+
39
+ files. findAll { f -> f. isDirectory() }
40
+ .findAll { f -> ! IGNORE_DIRS . any { d -> d == f. getName() } }
41
+ .findAll { f -> ! ignoreDirs. any { d -> d == f. getName() } }
42
+ .each { f -> {
43
+ if (f. getName() == DOCS_DIR ) {
44
+ def dest = getDestinationFromModule(output, f)
45
+ copyDirectory(f, new File (output, dest))
46
+ } else aggregateJavaDocRec(f, output)
47
+ } }
48
+ }
49
+
33
50
private static def createModulesPage (String name , String version , File file ) {
34
51
if (! file. isDirectory()) return
35
52
def files = file. listFiles()
@@ -42,12 +59,11 @@ class JavaDocUtils {
42
59
}
43
60
44
61
private static def parseResource (File parentFile , String resource , String name , String version , File [] files ) {
45
- JavaDocUtils . class . getResourceAsStream (" /${ resource} " ). withReader { reader ->
62
+ getResource (" /${ resource} " ). withReader { reader ->
46
63
new File (parentFile, resource). withWriter { writer ->
47
64
String line
48
65
while ((line = reader. readLine()) != null ) {
49
- line = line
50
- .replace(" %module_name%" , name)
66
+ line = line. replace(" %module_name%" , name)
51
67
.replace(" %module_version%" , version)
52
68
if (line. contains(MODULE_PLACEHOLDER ))
53
69
line = parseModulesPlaceholder(line, files)
@@ -60,38 +76,15 @@ class JavaDocUtils {
60
76
61
77
private static def parseModulesPlaceholder (String line , File [] files ) {
62
78
String output = " "
63
- for (f in files)
64
- JavaDocUtils . class. getResourceAsStream(" /${ MODULE_FORMAT_FILE} " ). withReader { r -> {
65
- String l
66
- while ((l = r. readLine()) != null )
67
- output + = l. replace(" %submodule_name%" , f. getName())
68
- .replace(" %submodule_path%" , " ${ f.getName()}${ File.separator} index.html" )
69
- }}
79
+ files. collect { it. getName() } .each { n -> getResource(" /${ MODULE_FORMAT_FILE} " ). withReader { r ->
80
+ String l
81
+ while ((l = r. readLine()) != null )
82
+ output + = l. replace(" %submodule_name%" , n)
83
+ .replace(" %submodule_path%" , " ${ n}${ File.separator} index.html" )
84
+ } }
70
85
return line. replace(MODULE_PLACEHOLDER , output)
71
86
}
72
87
73
- private static def aggregateJavaDocRec (File current , File output , String ... ignoreDirs ) {
74
- if (! current. isDirectory()) return
75
-
76
- def files = current. listFiles()
77
- if (files == null ) return
78
-
79
- main_loop :
80
- for (file in files) {
81
- def fileName = file. getName()
82
- for (dir in IGNORE_DIRS )
83
- if (fileName == dir) continue main_loop
84
- for (dir in ignoreDirs)
85
- if (fileName == dir) continue main_loop
86
-
87
- if (file. isDirectory())
88
- if (file. getName() == DOCS_DIR ) {
89
- def dest = getDestinationFromModule(output, file)
90
- copyDirectory(file, new File (output, dest))
91
- } else aggregateJavaDocRec(file, output)
92
- }
93
- }
94
-
95
88
/**
96
89
* Copies the given file.
97
90
*
@@ -103,8 +96,7 @@ class JavaDocUtils {
103
96
def files = src. listFiles()
104
97
dst. mkdirs()
105
98
if (files != null )
106
- for (file in files)
107
- copyDirectory(new File (src, file. getName()), new File (dst, file. getName()))
99
+ files. collect { it. getName() } .each { copyDirectory(new File (src, it), new File (dst, it)) }
108
100
} else Files . copy(src. toPath(), dst. toPath(), StandardCopyOption . REPLACE_EXISTING )
109
101
}
110
102
0 commit comments