This repository has been archived by the owner on May 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
74 lines (62 loc) · 1.67 KB
/
build.xml
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
<project name="ant-jsvalidate-example">
<scriptdef name="jsvalidate" language="javascript">
<element name="fileset" type="fileset"/>
<![CDATA[
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.BufferedReader);
var failures = 0;
function load(fname) {
var reader, content, line;
reader = new BufferedReader(new FileReader(fname));
content = '';
while (true) {
line = reader.readLine();
if (line === null) break;
content += line + '\n';
}
return content;
}
function validate(filename) {
var content, syntax, i, err;
try {
content = load(filename);
syntax = esprima.parse(content, { tolerant: true });
for (i = 0; i < syntax.errors.length; ++i) {
if (i === 0) self.log(filename + ':');
err = syntax.errors[i];
self.log(' ' + err.message);
++failures;
}
} catch (e) {
self.log(filename + ':');
self.log(' ' + e.toString());
++failures;
}
}
function validateFiles(filesets) {
var i, j, fileset, scanner, files, basedir, filename;
for (i = 0; i < filesets.size(); ++i) {
fileset = filesets.get(i);
scanner = fileset.getDirectoryScanner(project);
scanner.scan();
files = scanner.getIncludedFiles();
for(j = 0; j < files.length; j++) {
filename = fileset.getDir(project) + '/' + files[j];
validate(filename);
}
}
}
eval(load('lib/esprima.js'));
validateFiles(elements.get('fileset'));
if (failures > 0) self.fail('Invalid JavaScript!');
]]>
</scriptdef>
<target name="validate-javascript">
<jsvalidate>
<fileset dir="src/">
<include name="**/*.js"/>
</fileset>
</jsvalidate>
</target>
</project>