-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-common-plugins-inspector.xml
237 lines (208 loc) · 6.47 KB
/
build-common-plugins-inspector.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="build-common-plugins-inspector.xml">
<macrodef name="record-fail">
<attribute name="message" />
<sequential>
<echo append="true" file="../plugins-inspector.log">@{message}${line.separator}</echo>
</sequential>
</macrodef>
<target name="inspect-plugins">
<delete file="../plugins-inspector.log" />
<checksum file="build.xml" property="build.xml.checksum" />
<if>
<not>
<equals arg1="${build.xml.checksum}" arg2="aa45183ecb2cda43d255c7070a6225de" />
</not>
<then>
<record-fail message="build.xml is nonstandard." />
</then>
</if>
<exec dir="." executable="git">
<arg line="clean -d -f -x ." />
</exec>
<trycatch>
<try>
<antcall target="clean" />
</try>
<catch>
<record-fail message="Unable to clean all plugins." />
</catch>
</trycatch>
<trycatch>
<try>
<antcall target="compile" />
</try>
<catch>
<record-fail message="Unable to compile all plugins." />
</catch>
</trycatch>
<for param="module.name">
<path>
<dirset dir="." includes="*" />
</path>
<sequential>
<if>
<and>
<available file="@{module.name}/docroot" />
<available file="@{module.name}/src" />
</and>
<then>
<record-fail message="Module @{module.name} must not have both a "docroot" and a "src" directory." />
</then>
</if>
<if>
<and>
<not>
<available file="@{module.name}/docroot" />
</not>
<not>
<available file="@{module.name}/src" />
</not>
</and>
<then>
<record-fail message="Module @{module.name} must have a "docroot" or a "src" directory." />
</then>
</if>
<if>
<available file="@{module.name}/docroot/WEB-INF/liferay-hook.xml" />
<then>
<if>
<and>
<resourcecontains resource="@{module.name}/docroot/WEB-INF/liferay-hook.xml" substring="<language-properties>" />
<not>
<resourcecontains resource="@{module.name}/docroot/WEB-INF/liferay-hook.xml" substring="<language-properties>content/Language*.properties</language-properties>" />
</not>
</and>
<then>
<record-fail message="@{module.name}/docroot/WEB-INF/liferay-hook.xml has an nonstandard language-properties element." />
</then>
</if>
<if>
<and>
<resourcecontains resource="@{module.name}/docroot/WEB-INF/liferay-hook.xml" substring="<custom-jsp-dir>" />
<not>
<resourcecontains resource="@{module.name}/docroot/WEB-INF/liferay-hook.xml" substring="<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>" />
</not>
</and>
<then>
<record-fail message="@{module.name}/docroot/WEB-INF/liferay-hook.xml has a nonstandard custom-jsp-dir element." />
</then>
</if>
</then>
</if>
<if>
<resourcecontains resource="@{module.name}/docroot/WEB-INF/web.xml" substring="Invoker Filter" />
<then>
<record-fail message="@{module.name}/docroot/WEB-INF/web.xml contains generated code." />
</then>
</if>
<if>
<available file="@{module.name}/ivy.xml.MD5" />
<then>
<record-fail message="@{module.name}/ivy.xml.MD5 must not be checked into source control." />
</then>
</if>
<if>
<available file="@{module.name}/docroot/WEB-INF/lib" />
<then>
<record-fail message="@{module.name}/docroot/WEB-INF/lib must not be checked into source control." />
</then>
</if>
<if>
<available file="@{module.name}/docroot/WEB-INF/tld" />
<then>
<record-fail message="@{module.name}/docroot/WEB-INF/tld must not be checked into source control." />
</then>
</if>
<if>
<available file="@{module.name}/lib" />
<then>
<record-fail message="@{module.name}/lib must not be checked into source control." />
</then>
</if>
</sequential>
</for>
<exec dir="." executable="git" outputproperty="git.command.output">
<arg line="status ." />
</exec>
<if>
<available file=".gitignore" />
<then>
<echo file=".gitignore">/*/bin
/*/classes
/*/ivy.xml.MD5
/*/javadoc
/*/lib
/*/test-classes
/*/test-results</echo>
</then>
</if>
<resourcecount property="gitignore.count">
<fileset defaultexcludes="false" dir="." includes="**/.gitignore" />
</resourcecount>
<if>
<not>
<equals arg1="${gitignore.count}" arg2="0" />
</not>
<then>
<record-fail message="Plugins must not have custom .gitignore files." />
</then>
</if>
<if>
<or>
<contains string="${git.command.output}" substring="Changes not staged for commit" />
<contains string="${git.command.output}" substring="Untracked files" />
</or>
<then>
<record-fail message="Plugins must not generate modified files." />
</then>
</if>
<trycatch>
<try>
<loadfile property="plugins-inspector.log.content" srcFile="../plugins-inspector.log" />
<if>
<equals arg1="${basedir.name}" arg2="test-broken" />
<then>
<checksum file="../plugins-inspector.log" property="plugins-inspector.log.actual.checksum" />
<property name="plugins-inspector.log.expected.checksum" value="20988e2ed40f504cbc58c773e24b7fe5" />
<if>
<not>
<equals arg1="${plugins-inspector.log.actual.checksum}" arg2="${plugins-inspector.log.expected.checksum}" />
</not>
<then>
<copy file="../plugins-inspector.log" tofile="../plugins-inspector.log.test-broken" />
<echo>${plugins-inspector.log.content}</echo>
<fail>Plugins inspector is not detecting all errors. Expected "${plugins-inspector.log.expected.checksum}" but found "${plugins-inspector.log.actual.checksum}".</fail>
</then>
</if>
</then>
<elseif>
<equals arg1="${basedir.name}" arg2="test-working" />
<then>
<if>
<available file="../plugins-inspector.log" />
<then>
<echo>${plugins-inspector.log.content}</echo>
<fail>Plugins inspector is not detecting false errors.</fail>
</then>
</if>
</then>
</elseif>
<else>
<if>
<available file="../plugins-inspector.log" />
<then>
<echo>${plugins-inspector.log.content}</echo>
<fail>Plugins inspector detected errors.</fail>
</then>
</if>
</else>
</if>
</try>
<finally>
<delete file="../plugins-inspector.log" />
</finally>
</trycatch>
</target>
</project>