Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 449 lines (402 sloc) 16.9 KB
<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="name" value="Angry IP Scanner"/>
<property name="version" value="3.5"/>
<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"/>
<property name="win.installer.dir" value="${basedir}/ext/win-installer"/>
<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>
<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"/>
</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.7" target="1.7" optimize="@{optimize}" encoding="UTF-8">
<src path="@{path}"/>
<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>
<copy todir="${testbin}" overwrite="true">
<fileset dir="${testbin}" includes="**/*.class"/>
</copy>
</target>
<target name="test" depends="clean,compile,compile-tests">
<delete file="coverage.ec"/>
<junit haltonfailure="true" showoutput="true" fork="yes">
<classpath>
<path location="${testbin}"/>
<fileset dir="lib" includes="swt-${platform}.jar"/>
<fileset dir="lib" includes="**/*.jar"/>
</classpath>
<formatter type="brief" usefile="no"/>
<batchtest>
<fileset dir="${testbin}" includes="**/*Test.class"/>
</batchtest>
</junit>
</target>
<condition property="isRunningOnLinux">
<os name="Linux"/>
</condition>
<target name="package" depends="package-linux,package-linux64,package-win32,package-win64,package-mac,win-installer">
<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/dagger-2.8.jar" dest="${bin}.@{platform}"/>
<unzip src="lib/javax.inject-1.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-awt-gtk-*.so"/>
<include name="libswt-glx-gtk-*.so"/>
<include name="libswt-mozilla-*.so"/>
<include name="libswt-gnome-*.so"/>
<include name="libswt-xpcominit-gtk-*.so"/>
<include name="libswt-xulrunner-gtk-*.so"/>
<include name="libswt-webkit-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"/>
<include name="swt-webkit-*.dll"/>
<!-- Mac stuff -->
<include name="libswt-awt-*.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/browser"/>
<fileset dir="${bin}.@{platform}/org/eclipse/swt/ole"/>
<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/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/webkit"/>
<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/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 &lt;methods&gt;;
}
-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 {
&lt;methods&gt;;
}
-keep class org.eclipse.swt.internal.ole.win32.COMObject {
&lt;methods&gt;;
}
-keep class org.eclipse.swt.dnd.ClipboardProxy {
&lt;methods&gt;;
}
-keep class * {
&lt;methods&gt;;
&lt;fields&gt;;
}
-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 &quot;_topdir ${user.dir}/${dist}/rpm&quot; --define &quot;platform @{platform}&quot; -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/MacOS"/>
<replace file="${dist}/${name}.app/Contents/Info.plist">
<replacefilter token="APPNAME" value="${name}"/>
<replacefilter token="VERSION" value="${version}"/>
</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="${win.installer.dir}/InstallerConfig.nsh">
<replacefilter token="VERSION_MINOR" value="5"/>
<replacefilter token="VERSION" value="${version}"/>
</replace>
<copy file="${dist}/${ant.project.name}-win32-${version}.exe" tofile="${win.installer.dir}/AppFiles32/ipscan.exe"/>
<copy file="${dist}/${ant.project.name}-win64-${version}.exe" tofile="${win.installer.dir}/AppFiles64/ipscan.exe"/>
<exec dir="${win.installer.dir}" executable="wine">
<arg value="${win.installer.dir}/NSISPortable/App/NSIS/makensis.exe"/>
<arg value="Installer/Installer.nsi"/>
</exec>
<move file="${win.installer.dir}/ipscan-${version}-setup.exe" todir="${dist}"/>
<exec command="git checkout ext/win-installer/InstallerConfig.nsh"/>
</target>
</project>