forked from jonalv/cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createModulePages.groovy
198 lines (191 loc) · 6.35 KB
/
createModulePages.groovy
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/groovy
/* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import java.util.regex.Matcher
import java.util.regex.Pattern
def nightly = "http://pele.farmbio.uu.se/nightly-1.2.x/"
ant = new AntBuilder()
ant.delete(dir:"doc/modules")
ant.mkdir(dir:"doc/modules")
def basedir = new File("src/META-INF")
files = new ArrayList();
if (args[0] != null) {
files.add(new File(basedir, args[0] + ".cdkdepends"));
} else {
files = basedir.listFiles().grep(~/.*cdkdepends$/)
files.add(new File(basedir,"annotation.cdkdepends"))
files.add(new File(basedir,"interfaces.cdkdepends"))
}
files.each { file ->
println "Processing $file";
m = (file =~ ~/\/([-|\w]*)\.cdkdepends/)
module = m[0][1]
def writer = new StringWriter()
def builder = new groovy.xml.MarkupBuilder(writer)
builder.html(){
head(){
title("CDK Module: " + module){}
}
body(){
h1("CDK Module: " + module)
if (!module.contains("test")) {
h2("QA Reports")
p(){
localReport = new File("reports/result-"+module + ".txt")
if (localReport.exists()) {
// use local
localReport.eachLine {
if (it =~ ~/Tests\srun/) {
stats = it
}
}
span("JUnit: " + stats)
} else {
// use remote
junitURL = nightly+"test/result-"+module
stats = "";
try {
junitURL.toURL().eachLine {
if (it =~ ~/Tests\srun/) {
stats = it
}
}
a(href:junitURL,"JUnit")
span(": " + stats)
} catch (FileNotFoundException exc) {
} catch (SocketException exc) {}
}
}
}
p(){
a(href:nightly+"javadoc/$module/", "DocCheck Results")
}
p(){
span("PDM: ")
localReport = new File("reports/pmd/"+module + ".xml")
if (localReport.exists()) {
def pmd = null
try {
pmd = new XmlParser().parseText(localReport.text)
span("Violations=" + pmd.file.violation.size())
} catch (Exception exception) {}
} else {
a(href:nightly+"pmd/"+module+".html", "all")
}
localReport = new File("reports/pmd-unused/"+module + ".xml")
if (localReport.exists()) {
def pmd = null
try {
pmd = new XmlParser().parseText(localReport.text)
span("Violations=" + pmd.file.violation.size())
} catch (Exception exception) {}
} else {
a(href:nightly+"pmd-unused/"+module+".html", "unused")
}
localReport = new File("reports/pmd-migrating/"+module + ".xml")
if (localReport.exists()) {
def pmd = null
try {
pmd = new XmlParser().parseText(localReport.text)
span("Violations=" + pmd.file.violation.size())
} catch (Exception exception) {}
} else {
a(href:nightly+"pmd-migrating/"+module+".html", "migration")
}
}
h2("Depends")
p(){
if (file.exists()) {
b("CDK")
file.text.eachLine{
dependency = (it =~ ~/cdk-([-|\w]*)\.jar/)[0][1]
a(href:dependency+".html", dependency)
}
}
}
libdepends = new File(basedir, module + ".libdepends")
p(){
if (libdepends.exists()) {
b("Libraries")
ul() {
libdepends.text.eachLine{ libdep ->
if (libdep.length() > 0) {
p() {
span(libdep + ": ")
configFile = new File("jar/" + libdep + ".meta")
if (configFile.exists()) {
config = readProperties(configFile);
ul() {
config.keySet().each { section ->
libProps = config.get(section);
p() {
span(libProps.get("Library"))
if (libProps.containsKey("Version")) {
span(" " + libProps.get("Version"))
}
br()
if (libProps.containsKey("Copyright")) {
span(libProps.get("Copyright"))
br()
}
span(libProps.get("License"))
}
}
}
}
}
}
}
}
}
}
h2("Classes")
classes = new File("build/" + module + ".javafiles").text
classes.eachLine {
classURL = it.replaceAll(/.java/,"")
clazz = classURL.replaceAll(/\//,".")
a(href:nightly+"api/"+classURL+".html", clazz)
br()
}
}
}
new File("doc/modules/" + module + ".html").write(writer.toString())
}
public Map readProperties(File file) {
Map props = new HashMap();
Map sectionProps = null;
file.text.eachLine { line ->
line.trim();
if (line.startsWith("#")) {
// skip line
} else if (line.startsWith("[") && line.endsWith("]")) {
section = line.substring(line.indexOf("[")+1, line.indexOf("]"));
sectionProps = new HashMap();
props.put(section, sectionProps);
} else if (line.contains("=")) {
def keyValue = line.split("=")
if (sectionProps == null) {
print "ERROR: property without required section header";
System.exit(-1);
}
sectionProps.put(keyValue[0], keyValue[1]);
}
}
return props;
}