forked from angryip/ipscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
executable file
·489 lines (442 loc) · 19.4 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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<project basedir="." name="ipscan" default="info">
<property name="bin" value="ant-bin"/>
<property name="testbin" value="ant-tests"/>
<property name="dist" value="dist"/>
<property name="test" value="test"/>
<property name="resources" value="resources"/>
<property name="testresults" value="test-results"/>
<property name="name" value="Angry IP Scanner"/>
<property name="version" value="3.2.2"/>
<property name="main.class" value="net.azib.ipscan.Main"/>
<property name="swt" value="lib"/>
<property name="ext.src" value="ext/rocksaw/src:ext/vserv-tcpip/src"/>
<path id="cobertura.classpath">
<fileset dir="lib/testing">
<include name="cobertura.jar" />
<include name="*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<taskdef resource="proguard/ant/task.properties" classpath="ext/proguard/proguard.jar"/>
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="ext/launch4j/launch4j.jar:ext/launch4j/xstream.jar"/>
<patternset id="classpath.resources">
<exclude name="**/*.java"/>
<exclude name="**/*.ico"/>
<exclude name="**/icon?*.png"/>
</patternset>
<!-- detect current platform -->
<condition property="platform" value="linux">
<os name="Linux" arch="i386"/>
</condition>
<condition property="platform" value="linux64">
<or>
<os name="Linux" arch="amd64"/>
<os name="Linux" arch="ia64"/>
<os name="Linux" arch="x86_64"/>
</or>
</condition>
<condition property="platform" value="mac">
<os family="mac"/>
</condition>
<condition property="platform" value="win32">
<os family="windows" arch="i386"/>
</condition>
<condition property="platform" value="win64">
<or>
<os family="windows" arch="amd64"/>
<os family="windows" arch="ia64"/>
<os family="windows" arch="x86_64"/>
</or>
</condition>
<condition property="platform" value="unknown">
<not>
<isset property="platform"/>
</not>
</condition>
<target name="all" depends="clean,compile,compile-tests,test,package,clean_end"/>
<target name="linux" depends="clean,compile-linux,package-linux,clean_end"/>
<target name="linux64" depends="clean,compile-linux64,package-linux64,clean_end"/>
<target name="mac" depends="clean,compile-mac,package-mac,clean_end"/>
<target name="win32" depends="clean,compile-win32,package-win32,clean_end"/>
<target name="win64" depends="clean,compile-win64,package-win64,clean_end"/>
<target name="current">
<antcall target="${platform}"/>
</target>
<!-- this is run by cruise control continous integration -->
<target name="cruise" depends="clean,compile,compile-tests,package,clean_end"/>
<target name="info">
<echo message="This script will build ${name} ${version}"/>
<echo message="Targets (some may work only on Linux):"/>
<echo message=" all - runs tests and builds binaries for all OSs"/>
<echo message=" linux - builds only Linux 32-bit binary"/>
<echo message=" linux64 - builds only Linux 64-bit binary"/>
<echo message=" mac - builds only Mac binary"/>
<echo message=" win32 - builds only Windows binary"/>
<echo message=" win64 - builds only Windows 64-bit binary"/>
<echo message=" win-installer - packages a Windows installer (including both 32 and 64-bit binaries)"/>
<echo message=" current = ${platform}"/>
</target>
<target name="clean">
<delete dir="${dist}"/>
<antcall target="clean_end"/>
</target>
<target name="clean_end">
<delete dir="${bin}"/>
<delete dir="${testbin}"/>
<delete dir="${bin}.linux"/>
<delete dir="${bin}.linux64"/>
<delete dir="${bin}.win32"/>
<delete dir="${bin}.win64"/>
<delete dir="${bin}.mac"/>
<delete dir="${testresults}"/>
</target>
<macrodef name="compile">
<attribute name="path"/>
<attribute name="extpath" default=""/>
<attribute name="debug" default="true"/>
<attribute name="optimize" default="true"/>
<attribute name="platform" default="${platform}"/>
<attribute name="dest" default="${bin}.@{platform}"/>
<sequential>
<mkdir dir="@{dest}"/>
<javac destdir="@{dest}" debug="@{debug}" source="1.6" target="1.6" optimize="@{optimize}">
<src path="@{path}"/>
<src path="@{path}-platform/@{platform}"/>
<src path="@{extpath}"/>
<classpath>
<fileset dir="lib" includes="**/*.jar"/>
</classpath>
</javac>
<copy todir="@{dest}">
<fileset dir="@{path}">
<patternset refid="classpath.resources"/>
</fileset>
</copy>
<copy todir="@{dest}">
<fileset dir="${resources}">
<patternset refid="classpath.resources"/>
</fileset>
</copy>
</sequential>
</macrodef>
<target name="compile" depends="compile-linux,compile-linux64,compile-mac,compile-win32,compile-win64"/>
<target name="compile-linux">
<compile path="src" extpath="${ext.src}" platform="linux"/>
</target>
<target name="compile-linux64">
<compile path="src" extpath="${ext.src}" platform="linux64"/>
</target>
<target name="compile-mac">
<compile path="src" extpath="${ext.src}" platform="mac"/>
</target>
<target name="compile-win32">
<compile path="src" extpath="${ext.src}" platform="win32"/>
</target>
<target name="compile-win64">
<compile path="src" extpath="${ext.src}" platform="win64"/>
</target>
<target name="compile-tests">
<compile path="src" extpath="test:${ext.src}" dest="${testbin}" debug="true" optimize="false"/>
<copy todir="${testbin}" overwrite="true" verbose="true">
<fileset dir="test" excludes="**/*.java"/>
</copy>
<cobertura-instrument todir="${testbin}.instr">
<ignore regex="org.apache.log4j.*" />
<fileset dir="${testbin}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
<copy todir="${testbin}" overwrite="true">
<fileset dir="${testbin}.instr" includes="**/*.class"/>
</copy>
<delete dir="${testbin}.instr"/>
</target>
<target name="test">
<delete dir="${testresults}"/>
<mkdir dir="${testresults}"/>
<delete file="coverage.ec"/>
<junit haltonfailure="true" showoutput="true" fork="yes">
<sysproperty key="net.sourceforge.cobertura.datafile" file="${testresults}/cobertura.ser"/>
<classpath>
<path location="${testbin}"/>
<fileset dir="lib" includes="swt-${platform}.jar"/>
<fileset dir="lib" includes="**/*.jar"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${testresults}">
<fileset dir="${testbin}" includes="**/*Test.class"/>
</batchtest>
</junit>
<cobertura-report format="xml" destdir="test-coverage" srcdir="src" datafile="${testresults}/cobertura.ser"/>
<cobertura-report format="html" destdir="test-coverage" srcdir="src" datafile="${testresults}/cobertura.ser"/>
</target>
<condition property="isRunningOnLinux">
<os name="Linux"/>
</condition>
<target name="package" depends="package-linux,package-linux64,package-win32,package-win64,package-mac">
<echo message="Packaged jars are in the ${dist} directory"/>
</target>
<target name="build-info">
<tstamp/>
<property name="build.date" value="${TODAY}"/>
<exec command="git rev-parse HEAD" outputproperty="build.sha1"/>
</target>
<macrodef name="package-for">
<attribute name="platform"/>
<sequential>
<mkdir dir="${dist}"/>
<unzip src="lib/picocontainer-1.0.jar" dest="${bin}.@{platform}"/>
<unzip src="${swt}/swt-@{platform}.jar" dest="${bin}.@{platform}"/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${bin}.@{platform}/images" includes="**/*.svg"/>
<fileset dir="${bin}.@{platform}/META-INF"/>
<fileset dir="${bin}.@{platform}">
<include name="version.txt"/>
<!-- GTK stuff -->
<include name="libswt-atk-gtk-*.so"/>
<include name="libswt-awt-gtk-*.so"/>
<include name="libswt-glx-gtk-*.so"/>
<include name="libswt-mozilla-*.so"/>
<include name="libswt-gnome-*.so"/>
<include name="libswt-cairo-*.so"/>
<include name="libswt-xpcominit-gtk-*.so"/>
<include name="libswt-xulrunner-gtk-*.so"/>
<!-- Win32 stuff -->
<include name="swt-awt-*.dll"/>
<include name="swt-wgl-*.dll"/>
<include name="swt-gdip-*.dll"/>
<include name="swt-xpcominit-*.dll"/>
<include name="swt-xulrunner-*.dll"/>
<!-- Mac stuff -->
<include name="libswt-agl-*.jnilib"/>
<include name="libswt-xpcominit-*.jnilib"/>
<include name="libswt-xulrunner-*.jnilib"/>
</fileset>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/dnd">
<include name="D*"/>
<include name="H*"/>
<include name="F*"/>
<include name="N*"/>
<include name="R*"/>
<include name="S*"/>
<include name="Table*"/>
<include name="Tree*"/>
</fileset>
<!--fileset dir="${bin}.@{platform}/org/eclipse/swt/accessibility"/-->
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/accessibility"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/browser"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/ole"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/ole/win32" includes="I*"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/ole/win32" includes="O*"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/opengl"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/opengl"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/cairo"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/cde"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/theme"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/mozilla"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/gnome"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/internal/image">
<include name="JPEG*"/>
<include name="OS2*"/>
<include name="GIF*"/>
<include name="LZW*"/>
<include name="TIFF*"/>
<include name="Win*"/>
</fileset>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/custom"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/widgets">
<include name="Cool*"/>
<include name="Expand*"/>
<include name="Font*"/>
<include name="Color*"/>
<include name="Link*"/>
<include name="Tracker*"/>
<include name="Date*"/>
<include name="Tray*"/>
<include name="Tree*"/>
<include name="DateTime*"/>
<include name="Sash*"/>
</fileset>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/awt"/>
</delete>
<jar destfile="${dist}/${ant.project.name}-@{platform}-orig.jar" >
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Title" value="${name}"/>
<attribute name="Version" value="${version}"/>
<attribute name="Git-SHA1" value="${build.sha1}"/>
<attribute name="Build-Date" value="${build.date}"/>
<attribute name="Platform" value="@{platform}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="URL" value="http://www.angryip.org/"/>
</manifest>
<fileset dir="${bin}.@{platform}" includes="**/*"/>
</jar>
<!--proguard>
-injars ${dist}/${ant.project.name}-@{platform}-orig.jar
-outjars ${dist}/${ant.project.name}-@{platform}-${version}.jar
-libraryjars ${java.home}/lib/rt.jar
-libraryjars lib/jna-win32.jar
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers class * extends java.lang.Enum {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep public class * {
public protected *;
}
-keep public class org.eclipse.swt.widgets.Display {
<methods>;
}
-keep class org.eclipse.swt.internal.ole.win32.COMObject {
<methods>;
}
-keep class org.eclipse.swt.dnd.ClipboardProxy {
<methods>;
}
-keep class * {
<methods>;
<fields>;
}
-keep class org.eclipse.swt.internal.image.*FileFormat
-keep class * {
% *Proc(int);
% *Proc(int, int);
% *Proc(int, int, int);
% *Proc(long);
% *Proc(long, long);
% *Proc(long, long, long);
}
-ignorewarnings
</proguard-->
<copy file="${dist}/${ant.project.name}-@{platform}-orig.jar" tofile="${dist}/${ant.project.name}-@{platform}-${version}.jar"/>
<delete file="${dist}/${ant.project.name}-@{platform}-orig.jar"/>
</sequential>
</macrodef>
<target name="package-linux" depends="build-info">
<copy file="ext/rocksaw/lib/librocksaw32.so" tofile="${bin}.linux/librocksaw.so"/>
<package-for platform="linux"/>
<!-- now create deb package for Ubuntu and such -->
<antcall target="package-linux-deb-rpm"/>
</target>
<target name="package-linux64" depends="build-info">
<copy file="ext/rocksaw/lib/librocksaw64.so" tofile="${bin}.linux64/librocksaw.so"/>
<package-for platform="linux64"/>
<!-- now create deb package for Ubuntu and such -->
<antcall target="package-linux64-deb-rpm"/>
</target>
<target name="package-linux-deb-rpm" if="isRunningOnLinux">
<build-deb platform="linux" arch="i386"/>
<build-rpm platform="linux" arch="i386"/>
</target>
<target name="package-linux64-deb-rpm" if="isRunningOnLinux">
<build-deb platform="linux64" arch="amd64"/>
<build-rpm platform="linux64" arch="x86_64"/>
</target>
<macrodef name="build-deb">
<attribute name="platform" default="linux"/>
<attribute name="arch" default="i386"/>
<sequential>
<mkdir dir="${dist}/deb"/>
<copy todir="${dist}/deb">
<fileset dir="ext/deb-bundle"/>
</copy>
<copy file="${dist}/${ant.project.name}-@{platform}-${version}.jar" todir="${dist}/deb/usr/lib/ipscan"/>
<copy file="resources/images/icon128.png" tofile="${dist}/deb/usr/share/pixmaps/ipscan.png"/>
<replace file="${dist}/deb/DEBIAN/control">
<replacefilter token="VERSION" value="${version}"/>
<replacefilter token="ARCH" value="@{arch}"/>
</replace>
<exec executable="chmod" dir="${dist}">
<arg line="a+x deb/usr/bin/ipscan deb/usr/lib/ipscan/${ant.project.name}-@{platform}-${version}.jar"/>
</exec>
<echo message="Building .deb package using dpkg..."/>
<exec executable="fakeroot" dir="${dist}">
<arg line="dpkg-deb -b deb ${ant.project.name}_${version}_@{arch}.deb"/>
</exec>
<delete dir="${dist}/deb"/>
</sequential>
</macrodef>
<macrodef name="build-rpm">
<attribute name="platform" default="linux"/>
<attribute name="arch" default="i386"/>
<sequential>
<mkdir dir="${dist}/rpm"/>
<copy todir="${dist}/rpm">
<fileset dir="ext/rpmbuild"/>
</copy>
<replace file="${dist}/rpm/SPECS/ipscan.spec">
<replacefilter token="VERSION" value="${version}"/>
</replace>
<exec executable="rpmbuild" dir="${dist}/rpm">
<arg line="--target @{arch} --define "_topdir ${user.dir}/${dist}/rpm" --define "platform @{platform}" -bb SPECS/ipscan.spec"/>
</exec>
<move file="${dist}/rpm/RPMS/@{arch}/ipscan-${version}-1.@{arch}.rpm" todir="${dist}"/>
<delete dir="${dist}/rpm"/>
</sequential>
</macrodef>
<target name="package-win32" depends="build-info">
<copy file="ext/rocksaw/lib/rocksaw.dll" todir="${bin}.win32"/>
<unzip src="${swt}/jna-win32.jar" dest="${bin}.win32"/>
<package-for platform="win32"/>
<package-exe-for platform="win32"/>
</target>
<target name="package-win64" depends="build-info">
<!--<copy file="ext/rocksaw/lib/rocksaw.dll" todir="${bin}.win64"/>-->
<unzip src="${swt}/jna-win64.jar" dest="${bin}.win64"/>
<package-for platform="win64"/>
<package-exe-for platform="win64"/>
</target>
<macrodef name="package-exe-for">
<attribute name="platform"/>
<sequential>
<copy file="ext/launch4j/ipscan.xml" todir="${dist}"/>
<replace file="${dist}/ipscan.xml">
<replacefilter token="FILENAME_IN" value="${ant.project.name}-@{platform}-${version}.jar"/>
<replacefilter token="FILENAME_OUT" value="${ant.project.name}-@{platform}-${version}.exe"/>
<replacefilter token="VERSION" value="${version}"/>
</replace>
<launch4j configFile="${dist}/ipscan.xml"/>
<delete file="${dist}/ipscan.xml"/>
<delete file="${dist}/${ant.project.name}-@{platform}-${version}.jar"/>
</sequential>
</macrodef>
<target name="package-mac" depends="build-info">
<!--<copy file="ext/rocksaw/lib/todo-librocksaw.jnilib" todir="${bin}.mac"/>-->
<package-for platform="mac"/>
<copy todir="${dist}">
<fileset dir="ext/mac-bundle"/>
</copy>
<copy file="${dist}/${ant.project.name}-mac-${version}.jar" todir="${dist}/${name}.app/Contents/Resources/Java"/>
<replace file="${dist}/${name}.app/Contents/Info.plist">
<replacefilter token="APPNAME" value="${name}"/>
<replacefilter token="VERSION" value="${version}"/>
<replacefilter token="JARFILE" value="${ant.project.name}-mac-${version}.jar"/>
<replacefilter token="MAINCLASS" value="${main.class}"/>
</replace>
<zip destfile="${dist}/${ant.project.name}-mac-${version}.zip">
<zipfileset dir="${dist}/${name}.app" excludes="Contents/MacOS/ipscan" prefix="${name}.app"/>
<!-- this one should be executable -->
<zipfileset dir="${dist}/${name}.app" includes="Contents/MacOS/ipscan" prefix="${name}.app" filemode="755"/>
</zip>
<delete dir="${dist}/${name}.app"/>
<delete file="${dist}/${ant.project.name}-mac-${version}.jar"/>
</target>
<target name="win-installer" depends="clean,compile-win32,compile-win64,package-win32,package-win64">
<replace file="ext/win-installer/InstallerConfig.nsh">
<replacefilter token="VERSION_MINOR" value="2"/>
<replacefilter token="VERSION" value="${version}"/>
</replace>
<copy file="${dist}/${ant.project.name}-win32-${version}.exe" tofile="ext/win-installer/AppFiles32/ipscan.exe"/>
<copy file="${dist}/${ant.project.name}-win64-${version}.exe" tofile="ext/win-installer/AppFiles64/ipscan.exe"/>
<exec dir="ext/win-installer" command="NSISPortable/NSISPortable.exe Installer/Installer.nsi"/>
<move file="ext/win-installer/ipscan-${version}-setup.exe" todir="${dist}"/>
<exec command="git checkout ext/win-installer/InstallerConfig.nsh"/>
</target>
</project>