-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
357 lines (322 loc) · 12.3 KB
/
build.xml
File metadata and controls
357 lines (322 loc) · 12.3 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
Ant build script for the assertion study project.
-->
<project name="Simple assertion study survey" default="setup" basedir=".">
<!-- The root folder. The default is "" (current folder); can be
overridden at the command line by setting -Dreporoot=xyz -->
<property name="reporoot" value=""/>
<!-- The folder where libraries (ant-contrib, etc.) will be downloaded
if necessary. Trailing slash is mandatory. -->
<property name="build.libdir" value="${reporoot}lib"/>
<!-- The folder where repositories will be cloned -->
<property name="repofolder" value="${reporoot}Repositories"/>
<!-- The folder where repositories will be cloned -->
<property name="reportfolder" value="${reporoot}Reports"/>
<!-- The folder where profiles are stored -->
<property name="profilefolder" value="${reporoot}Profiles"/>
<!-- The version of the tool to download -->
<property name="toolversion" value="1.3"/>
<!-- The folder containing the cache -->
<property name="cachefolder" value="${reporoot}.cache"/>
<!-- The name of the tool to download -->
<property name="toolname" value="piglet-${toolversion}"/>
<!-- Whether to use the "printout" output option -->
<property name="printout" value="false"/>
<!-- Macro to call git -->
<macrodef name="git">
<attribute name="command" />
<attribute name="options" default="" />
<attribute name="dir" default="" />
<attribute name="failerror" default="false" />
<element name="args" optional="true" />
<sequential>
<echo message="git dir @{dir}" />
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}" failonerror="@{failerror}">
<arg line="@{command} @{options}" />
<args />
</exec>
</sequential>
</macrodef>
<!-- Macro to call git clone. Note -->
<macrodef name="git-clone">
<attribute name="repository" />
<attribute name="dest" />
<attribute name="dir" />
<attribute name="options" default="" />
<attribute name="failerror" default="false" />
<sequential>
<git command="clone" dir="@{dir}" options="@{options}" failerror="@{failerror}">
<args>
<arg value="@{repository}" />
<arg value="@{dest}" />
</args>
</git>
</sequential>
</macrodef>
<!-- Macro to call git rev-parse (used to get hash) -->
<macrodef name="git-rev-parse">
<attribute name="dir" />
<attribute name="failerror" default="false" />
<sequential>
<exec executable="git" dir="@{dir}" failonerror="@{failerror}" outputproperty="gitout">
<arg line="rev-parse HEAD" />
</exec>
<propertyregex property="subhash.tmp" override="true" input="${gitout}" regexp="^(\d{8})" select="\1" />
<var name="subhash" value="${subhash.tmp}"/>
<echo message="@{dir} ${subhash}"/>
</sequential>
</macrodef>
<!-- Macro to call SVN checkout -->
<macrodef name="svn">
<attribute name="repository"/>
<attribute name="dest"/>
<attribute name="dir" default="" />
<attribute name="failerror" default="false" />
<sequential>
<exec executable="svn" dir="@{dir}" failonerror="@{failerror}">
<arg value="co" />
<arg value="@{repository}"/>
<arg value="@{dest}"/>
</exec>
</sequential>
</macrodef>
<!-- Macro to clone only if target directory does not exist. Note that
after cloning, all non-Java files are deleted. -->
<macrodef name="cloneif">
<attribute name="repo" />
<attribute name="dir" />
<sequential>
<if>
<available file="@{dir}" type="dir"/>
<then/>
<else>
<git-clone repository="@{repo}" dest="@{dir}" dir="" options="--depth 1"/>
<filter-folder dir="@{dir}"/>
</else>
</if>
</sequential>
</macrodef>
<!-- Macro to perform a CVS checkout only if target directory does not
exist -->
<macrodef name="checkoutif">
<attribute name="repo"/>
<attribute name="dir"/>
<attribute name="package"/>
<sequential>
<if>
<available file="@{dir}" type="dir"/>
<then/>
<else>
<cvs cvsRoot="@{repo}" package="@{package}" dest="@{dir}" compression="true"/>
</else>
</if>
</sequential>
</macrodef>
<!-- Macro to perform an SVN checkout only if target directory does not
exist -->
<macrodef name="svncheckoutif">
<attribute name="repo"/>
<attribute name="dir"/>
<sequential>
<if>
<available file="@{dir}" type="dir"/>
<then/>
<else>
<svn repository="@{repo}" dest="@{dir}"/>
</else>
</if>
</sequential>
</macrodef>
<!-- Macro to remove all non-Java files from a folder -->
<macrodef name="filter-folder">
<attribute name="dir"/>
<sequential>
<delete>
<fileset dir="@{dir}" includes="**/*" excludes="**/*.java, **/.git/**, **/*.jar"/>
</delete>
<deleteEmptyFolders dir="@{dir}"/>
</sequential>
</macrodef>
<!-- Macro to find and delete empty folders under dir -->
<macrodef name="deleteEmptyFolders">
<attribute name="dir"/>
<sequential>
<delete includeemptydirs="true">
<fileset dir="@{dir}" >
<and>
<size value="0"/>
<type type="dir"/>
</and>
</fileset>
</delete>
</sequential>
</macrodef>
<!-- Target: ant-contrib.
Downloads ant-contrib, only if it does not exist
-->
<condition property="ant-contrib.absent" value="false" else="true">
<available file="${build.libdir}/ant-contrib-1.0b3.jar"/>
</condition>
<target name="ant-contrib" if="${ant-contrib.absent}" description="Install ant-contrib if not present" unless="offline">
<echo message="ant-contrib is not installed. Downloading..." level="info"/>
<mkdir dir="${build.libdir}"/>
<get src="http://sylvainhalle.github.io/AntRun/dependencies/ant-contrib-1.0b3-bin.zip" dest="${build.libdir}/ant-contrib-1.0b3-bin.zip"/>
<unzip src="${build.libdir}/ant-contrib-1.0b3-bin.zip" dest="${build.libdir}">
<patternset>
<include name="**/*.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
</target>
<!-- Target: initialization
All other targets should ultimately
depend on this one (except perhaps very simple ones).
-->
<target name="init" depends="ant-contrib" description="Initialize the project">
<!-- Load ant-contrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${build.libdir}/ant-contrib-1.0b3.jar"/>
<mkdir dir="${reportfolder}"/>
</target>
<!-- Target: download-tool
Downloads the tool if not present
-->
<condition property="piglet.absent" value="false" else="true">
<available file="${build.libdir}/${toolname}.jar"/>
</condition>
<target name="download-tool" depends="init" if="${piglet.absent}" description="Download the tool" unless="offline">
<get src="https://github.com/liflab/piglet/releases/download/v${toolversion}/${toolname}.jar" dest="${build.libdir}/${toolname}.jar"/>
</target>
<!-- Target: clone
Clones the repositories
-->
<target name="clone" depends="init" description="Clones the repositories" unless="offline">
<cloneif repo="https://github.com/apache/hadoop.git" dir="${repofolder}/hadoop"/>
<cloneif repo="https://github.com/apache/ant.git" dir="${repofolder}/ant"/>
<cloneif repo="https://github.com/bootique/bootique.git" dir="${repofolder}/bootique"/>
<cloneif repo="https://github.com/elastic/elasticsearch.git" dir="${repofolder}/elasticsearch"/>
<cloneif repo="https://github.com/oracle/graal.git" dir="${repofolder}/graalvm"/>
<cloneif repo="https://github.com/google/guava.git" dir="${repofolder}/guava"/>
<cloneif repo="https://github.com/JetBrains/intellij-community.git" dir="${repofolder}/intellij"/>
<cloneif repo="https://github.com/JabRef/jabref.git" dir="${repofolder}/jabref"/>
<cloneif repo="https://github.com/jenkinsci/jenkins.git" dir="${repofolder}/jenkins"/>
<svncheckoutif repo="http://oss.mars.asu.edu/svn/jmars/" dir="${repofolder}/jmars"/>
<checkoutif repo=":pserver:anonymous@gee.cs.oswego.edu/home/jsr166/jsr166" dir="${repofolder}/jsr166" package="jsr166"/>
<cloneif repo="https://anongit.freedesktop.org/git/libreoffice/core.git" dir="${repofolder}/libreoffice"/>
<cloneif repo="https://github.com/LWJGL/lwjgl3.git" dir="${repofolder}/lwjgl"/>
<cloneif repo="https://github.com/Evolveum/midpoint.git" dir="${repofolder}/midpoint"/>
<cloneif repo="https://github.com/neo4j/neo4j.git" dir="${repofolder}/neo4j"/>
<cloneif repo="https://github.com/SonarSource/sonarqube.git" dir="${repofolder}/sonarqube"/>
<cloneif repo="https://github.com/sylvainhalle/textidote.git" dir="${repofolder}/textidote"/>
<cloneif repo="https://github.com/thunderbird/thunderbird-android.git" dir="${repofolder}/thunderbird"/>
<cloneif repo="https://github.com/nasa/ziggy.git" dir="${repofolder}/ziggy"/>
</target>
<!-- Target: hashes
Fetches the hash of the latest commit in each project -->
<target name="hashes" depends="init" description="Fetches the hash of the latest commit in each project">
<foreach target="hash" param="folder">
<path>
<dirset dir="${repofolder}">
<include name="*"/>
</dirset>
</path>
</foreach>
</target>
<!-- Target: hash
Fetches the hash of the latest commit in one project -->
<target name="hash" depends="init" description="Fetches the hash of the latest commit in one project">
<basename property="last.folder" file="${folder}"/>
<exec executable="git" dir="${folder}" failonerror="false" outputproperty="gitout" resultproperty="errcode">
<arg line="rev-parse --short HEAD" />
</exec>
<if>
<available file="${folder}/.git" type="dir"/>
<then>
<display-hash dir="${last.folder}" hash="${gitout}"/>
</then>
<else>
<display-hash dir="${last.folder}" hash="?"/>
</else>
</if>
</target>
<!-- Macro to display the latest commit hash of a project -->
<macrodef name="display-hash">
<attribute name="dir"/>
<attribute name="hash"/>
<sequential>
<echo message="@{dir} @{hash}"/>
</sequential>
</macrodef>
<!-- Target: setup
Main target that performs all the installation steps
-->
<target name="setup" description="Performs all the installation steps" depends="clone,download-tool">
<mkdir dir="${cachefolder}"/>
</target>
<!-- Target: clean
Removes all reports and cache files
-->
<target name="clean" description="Removes all reports and cache files">
<delete dir="${cachefolder}" quiet="true"/>
<mkdir dir="${cachefolder}"/>
<delete>
<fileset dir="${reportfolder}" includes="*.html"/>
</delete>
</target>
<!-- Target: filter
Remove all non-Java files -->
<target name="filter" depends="init" description="Removes all non-Java files from repositories">
<filter-folder dir="${repofolder}/${project}"/>
</target>
<!-- Launches the tool to analyze one project -->
<macrodef name="launch">
<attribute name="repo"/>
<sequential>
<if>
<equals arg1="${printout}" arg2="true"/>
<then>
<java jar="${build.libdir}/${toolname}.jar" fork="true">
<arg line="--printout ${profilefolder}/@{repo}.profile"/>
</java>
</then>
<else>
<java jar="${build.libdir}/${toolname}.jar" fork="true">
<arg line="${profilefolder}/@{repo}.profile"/>
</java>
</else>
</if>
</sequential>
</macrodef>
<!-- Target: analyze
Analyzes a specific project
-->
<target name="analyze" depends="setup" description="Analyzes a repository">
<launch repo="${project}"/>
</target>
<!-- Target: analyze-all
Analyzes all projects
-->
<target name="analyze-all" depends="setup" description="Analyzes all repositories">
<foreach target="analyze" param="project" list="ant,bootique,elasticsearch,graalvm,guava,hadoop,intellij,jabref,jenkins,jmars,jsr166,libreoffice,lwjgl,midpoint,neo4j,sonarqube,synthia,textidote,thunderbird,ziggy" parallel="false"/>
</target>
<!-- Target: filter-all
Filters all projects
-->
<target name="filter-all" depends="init" description="Filters all repositories">
<foreach target="filter" param="project" list="ant,bootique,elasticsearch,graalvm,guava,hadoop,intellij,jabref,jenkins,jmars,jsr166,libreoffice,lwjgl,midpoint,neo4j,sonarqube,synthia,textidote,thunderbird,ziggy" parallel="false"/>
</target>
<!-- Target: show-properties
Prints all the properties.
-->
<target name="show-properties" depends="init" description="Print all properties">
<echoproperties/>
</target>
<!-- Target: dummy
Do nothing. This is only to test the build file
-->
<target name="dummy" description="Do nothing">
<!-- Do nothing -->
</target>
</project>
<!-- :tabWidth=2: -->