Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 199 lines (191 sloc) 6.503 kb
5f16704 @egonw Added set up for creating module HTML pages
authored
1 #!/usr/bin/groovy
2
8dee40d @egonw Added missing copyright/license header
authored
3 /* Copyright (C) 2009 Egon Willighagen <egonw@users.sf.net>
4 *
5 * Contact: cdk-devel@lists.sourceforge.net
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
e4a90b1 @egonw Added info for dependencies
authored
21 import java.util.regex.Matcher
22 import java.util.regex.Pattern
8dee40d @egonw Added missing copyright/license header
authored
23
917cc7e @egonw Added link to JUnit stats
authored
24 def nightly = "http://pele.farmbio.uu.se/nightly-1.2.x/"
a917c82 @egonw Added list of classes in the module, with links to Nightly@Pele
authored
25
5f16704 @egonw Added set up for creating module HTML pages
authored
26 ant = new AntBuilder()
27
28 ant.delete(dir:"doc/modules")
29 ant.mkdir(dir:"doc/modules")
30
31 def basedir = new File("src/META-INF")
fcdad41 @egonw Added option to run it on just one module
authored
32 files = new ArrayList();
33 if (args[0] != null) {
34 files.add(new File(basedir, args[0] + ".cdkdepends"));
35 } else {
36 files = basedir.listFiles().grep(~/.*cdkdepends$/)
37 files.add(new File(basedir,"annotation.cdkdepends"))
38 files.add(new File(basedir,"interfaces.cdkdepends"))
39 }
7693308 @egonw Output where it is working on
authored
40 files.each { file ->
41 println "Processing $file";
5f16704 @egonw Added set up for creating module HTML pages
authored
42 m = (file =~ ~/\/([-|\w]*)\.cdkdepends/)
43 module = m[0][1]
44
45 def writer = new StringWriter()
46 def builder = new groovy.xml.MarkupBuilder(writer)
47 builder.html(){
48 head(){
49 title("CDK Module: " + module){}
50 }
51 body(){
52 h1("CDK Module: " + module)
917cc7e @egonw Added link to JUnit stats
authored
53 if (!module.contains("test")) {
54 h2("QA Reports")
55 p(){
35550bd @egonw Use local PMD and JUnit reports if available
authored
56 localReport = new File("reports/result-"+module + ".txt")
57 if (localReport.exists()) {
58 // use local
59 localReport.eachLine {
917cc7e @egonw Added link to JUnit stats
authored
60 if (it =~ ~/Tests\srun/) {
61 stats = it
62 }
63 }
35550bd @egonw Use local PMD and JUnit reports if available
authored
64 span("JUnit: " + stats)
65 } else {
66 // use remote
67 junitURL = nightly+"test/result-"+module
68 stats = "";
69 try {
70 junitURL.toURL().eachLine {
71 if (it =~ ~/Tests\srun/) {
72 stats = it
73 }
74 }
75 a(href:junitURL,"JUnit")
76 span(": " + stats)
77 } catch (FileNotFoundException exc) {
78 } catch (SocketException exc) {}
79 }
917cc7e @egonw Added link to JUnit stats
authored
80 }
81 }
cbdffa7 @egonw Added links to PMD pages
authored
82 p(){
83 a(href:nightly+"javadoc/$module/", "DocCheck Results")
84 }
85 p(){
86 span("PDM: ")
35550bd @egonw Use local PMD and JUnit reports if available
authored
87 localReport = new File("reports/pmd/"+module + ".xml")
88 if (localReport.exists()) {
89 def pmd = null
90 try {
91 pmd = new XmlParser().parseText(localReport.text)
92 span("Violations=" + pmd.file.violation.size())
93 } catch (Exception exception) {}
94 } else {
95 a(href:nightly+"pmd/"+module+".html", "all")
96 }
97 localReport = new File("reports/pmd-unused/"+module + ".xml")
98 if (localReport.exists()) {
99 def pmd = null
100 try {
101 pmd = new XmlParser().parseText(localReport.text)
102 span("Violations=" + pmd.file.violation.size())
103 } catch (Exception exception) {}
104 } else {
105 a(href:nightly+"pmd-unused/"+module+".html", "unused")
106 }
107 localReport = new File("reports/pmd-migrating/"+module + ".xml")
108 if (localReport.exists()) {
109 def pmd = null
110 try {
111 pmd = new XmlParser().parseText(localReport.text)
112 span("Violations=" + pmd.file.violation.size())
113 } catch (Exception exception) {}
114 } else {
115 a(href:nightly+"pmd-migrating/"+module+".html", "migration")
116 }
cbdffa7 @egonw Added links to PMD pages
authored
117 }
ede2572 @egonw Added set up for creating module HTML pages
authored
118 h2("Depends")
119 p(){
120 if (file.exists()) {
121 b("CDK")
122 file.text.eachLine{
123 dependency = (it =~ ~/cdk-([-|\w]*)\.jar/)[0][1]
124 a(href:dependency+".html", dependency)
125 }
126 }
127 }
128 libdepends = new File(basedir, module + ".libdepends")
129 p(){
130 if (libdepends.exists()) {
131 b("Libraries")
5b5e54d @egonw Created a list, to be able to add license information
authored
132 ul() {
133 libdepends.text.eachLine{ libdep ->
134 if (libdep.length() > 0) {
135 p() {
e4a90b1 @egonw Added info for dependencies
authored
136 span(libdep + ": ")
137 configFile = new File("jar/" + libdep + ".meta")
138 if (configFile.exists()) {
139 config = readProperties(configFile);
140 ul() {
141 config.keySet().each { section ->
142 libProps = config.get(section);
143 p() {
144 span(libProps.get("Library"))
145 if (libProps.containsKey("Version")) {
146 span(" " + libProps.get("Version"))
147 }
148 br()
149 if (libProps.containsKey("Copyright")) {
150 span(libProps.get("Copyright"))
151 br()
152 }
153 span(libProps.get("License"))
154 }
155 }
156 }
157 }
5b5e54d @egonw Created a list, to be able to add license information
authored
158 }
159 }
160 }
ede2572 @egonw Added set up for creating module HTML pages
authored
161 }
162 }
163 }
a917c82 @egonw Added list of classes in the module, with links to Nightly@Pele
authored
164 h2("Classes")
165 classes = new File("build/" + module + ".javafiles").text
166 classes.eachLine {
167 classURL = it.replaceAll(/.java/,"")
168 clazz = classURL.replaceAll(/\//,".")
917cc7e @egonw Added link to JUnit stats
authored
169 a(href:nightly+"api/"+classURL+".html", clazz)
a917c82 @egonw Added list of classes in the module, with links to Nightly@Pele
authored
170 br()
171 }
ede2572 @egonw Added set up for creating module HTML pages
authored
172 }
5f16704 @egonw Added set up for creating module HTML pages
authored
173 }
174 new File("doc/modules/" + module + ".html").write(writer.toString())
175 }
176
e4a90b1 @egonw Added info for dependencies
authored
177 public Map readProperties(File file) {
178 Map props = new HashMap();
179 Map sectionProps = null;
180 file.text.eachLine { line ->
181 line.trim();
182 if (line.startsWith("#")) {
183 // skip line
184 } else if (line.startsWith("[") && line.endsWith("]")) {
185 section = line.substring(line.indexOf("[")+1, line.indexOf("]"));
186 sectionProps = new HashMap();
187 props.put(section, sectionProps);
188 } else if (line.contains("=")) {
189 def keyValue = line.split("=")
190 if (sectionProps == null) {
191 print "ERROR: property without required section header";
192 System.exit(-1);
193 }
194 sectionProps.put(keyValue[0], keyValue[1]);
195 }
196 }
197 return props;
198 }
Something went wrong with that request. Please try again.