ipscan/build.xml

304 lines
11 KiB
XML
Executable File

<project basedir="." name="ipscan" default="all">
<property name="bin" value="ant-bin"/>
<property name="dist" value="dist"/>
<property name="ext" value="ext"/>
<property name="src" value="src"/>
<property name="resources" value="resources"/>
<property name="testresults" value="testresults"/>
<property name="name" value="Angry IP Scanner"/>
<property name="version" value="3.0-beta1"/>
<property name="main.class" value="net.azib.ipscan.Main"/>
<property name="swt" value="ext/swt"/>
<property name="ext.src" value="${ext}/rocksaw/src:${ext}/vserv-tcpip/src"/>
<path id="test.path" path="${bin}"/>
<property name="emma.dir" value="${ext}/emma"/>
<path id="emma.lib">
<pathelement location="${emma.dir}/emma.jar" />
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<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>
<target name="all" depends="cleanup,compile,package,cleanup_end"/>
<!--<target name="all" depends="cleanup,compile,compile-tests,do-test,package,cleanup_end"/>-->
<target name="cleanup">
<delete dir="${bin}"/>
<delete dir="${bin}.linux"/>
<delete dir="${bin}.win32"/>
<delete dir="${bin}.mac"/>
<delete dir="${testresults}"/>
<delete file="retroguard.log"/>
</target>
<target name="cleanup_end">
<antcall target="cleanup"/>
</target>
<macrodef name="compile">
<attribute name="path"/>
<attribute name="dest" default="@{path}"/>
<attribute name="extpath" default=""/>
<attribute name="debug" default="false"/>
<attribute name="optimize" default="true"/>
<sequential>
<mkdir dir="${bin}"/>
<javac destdir="${bin}" debug="@{debug}" source="1.5" target="1.5" optimize="@{optimize}">
<src path="@{path}"/>
<src path="@{extpath}"/>
<classpath>
<fileset dir="${ext}" includes="**/*.jar"/>
</classpath>
</javac>
<copy todir="${bin}">
<fileset dir="@{path}">
<patternset refid="classpath.resources"/>
</fileset>
</copy>
<copy todir="${bin}">
<fileset dir="${resources}">
<patternset refid="classpath.resources"/>
</fileset>
</copy>
</sequential>
</macrodef>
<target name="compile">
<compile path="${src}" extpath="${ext.src}"/>
</target>
<target name="compile-tests">
<compile path="${src}"/>
<emma>
<instr instrpathref="test.path" destdir="${bin}.instr" metadatafile="${testresults}/metadata.emma" merge="false" filter="net.azib.ipscan.*"/>
</emma>
<copy todir="${bin}" overwrite="true">
<fileset dir="${bin}.instr" includes="**/*.class"/>
</copy>
<delete dir="${bin}.instr"/>
</target>
<target name="do-test">
<delete dir="${testresults}"/>
<mkdir dir="${testresults}"/>
<delete file="coverage.ec"/>
<junit haltonfailure="true" showoutput="true" dir="${basedir}" fork="on" forkmode="once">
<classpath>
<dirset dir="${bin}"/>
<fileset dir="${swt}" includes="*.jar"/>
<path refid="emma.lib"/>
</classpath>
<formatter type="brief"/>
<batchtest todir="${testresults}">
<fileset dir="${bin}" includes="**/*Test.class"/>
</batchtest>
</junit>
<emma>
<report sourcepath="${src}" encoding="UTF-8">
<fileset dir="${basedir}" includes="coverage.ec"/>
<fileset dir="${testresults}" includes="*.emma"/>
<txt outfile="${testresults}/coverage.txt"/>
<html outfile="${testresults}/coverage.html"/>
</report>
</emma>
</target>
<target name="package" depends="svn-info,package-linux,package-win32,package-mac"/>
<target name="svn-info">
<!-- TODO: make this more cross-platform (most likely this will fail on windows) -->
<exec command="svn info . --xml" output="svn-info.xml"/>
<xmlproperty file="svn-info.xml" prefix="svn"/>
<delete file="svn-info.xml"/>
<property name="build.number" value="${svn.info.entry(revision)}"/>
<tstamp/>
<property name="build.date" value="${TODAY}"/>
</target>
<macrodef name="package-for">
<attribute name="platform"/>
<attribute name="librocksaw"/>
<sequential>
<delete dir="${dist}.@{platform}"/>
<mkdir dir="${dist}.@{platform}"/>
<delete dir="${bin}.@{platform}"/>
<mkdir dir="${bin}.@{platform}"/>
<unzip src="${ext}/picocontainer/picocontainer-1.0.jar" dest="${bin}"/>
<unzip src="${swt}/swt-@{platform}.jar" dest="${bin}.@{platform}"/>
<copy file="${ext}/rocksaw/lib/@{librocksaw}" todir="${bin}.@{platform}"/>
<copy file="${ext}/winping/lib/winping.dll" todir="${bin}.win32"/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${bin}/META-INF"/>
<fileset dir="${bin}/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"/>
<!-- Win32 stuff -->
<include name="swt-awt-*.dll"/>
<include name="swt-wgl-*.dll"/>
<include name="swt-gdip-*.dll"/>
<!-- Mac stuff -->
<include name="libswt-agl-*.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/internal/gdip"/>
<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="ToolBar*"/>
<include name="ToolItem*"/>
<include name="Tracker*"/>
<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}.@{platform}/${ant.project.name}-orig.jar" >
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Title" value="${name}"/>
<attribute name="Version" value="${version}"/>
<attribute name="Build" value="${build.number}"/>
<attribute name="Build-Date" value="${build.date}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="URL" value="http://www.azib.net/ipscan/"/>
</manifest>
<fileset dir="${bin}" includes="**/*"/>
<fileset dir="${bin}.@{platform}" includes="**/*"/>
</jar>
<proguard>
-injars ${dist}.@{platform}/${ant.project.name}-orig.jar
-outjars ${dist}.@{platform}/${ant.project.name}-@{platform}-${version}.jar
-libraryjars ${java.home}/lib/rt.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.image.*FileFormat
-keep class org.eclipse.swt.accessibility.** {
static &lt;methods&gt;;
}
</proguard>
</sequential>
</macrodef>
<target name="package-linux">
<package-for platform="linux" librocksaw="librocksaw.so"/>
</target>
<target name="package-win32">
<package-for platform="win32" librocksaw="rocksaw.dll"/>
<!-- now create a windows exe file (currently works only on Linux) -->
<copy file="${ext}/launch4j/ipscan.xml" todir="${dist}.win32"/>
<replace file="${dist}.win32/ipscan.xml">
<replacefilter token="ipscan.jar" value="${ant.project.name}-win32-${version}.jar"/>
<replacefilter token="ipscan.exe" value="${ant.project.name}-win32-${version}.exe"/>
</replace>
<launch4j configFile="${dist}.win32/ipscan.xml"/>
<delete file="${dist}.win32/ipscan.xml"/>
<delete file="${ant.project.name}-win32-${version}.jar"/>
</target>
<!-- Note: this task was tested only on Linux -->
<target name="package-mac">
<package-for platform="mac" librocksaw="todo-librocksaw.jnilib"/>
<copy todir="${dist}.mac">
<fileset dir="${ext}/mac-bundle"/>
</copy>
<copy file="${dist}.mac/${ant.project.name}-mac-${version}.jar" todir="${dist}.mac/${name}.app/Contents/Resources/Java"/>
<exec executable="ln">
<arg line="-s /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub"/>
<arg value="${dist}.mac/${name}.app/Contents/MacOS/ipscan"/>
</exec>
<replace file="${dist}.mac/${name}.app/Contents/Info.plist">
<replacefilter token="APPNAME" value="${name}"/>
<replacefilter token="VERSION" value="${version}"/>
<replacefilter token="BUILD" value="${build.number}"/>
<replacefilter token="JARFILE" value="${ant.project.name}-mac-${version}.jar"/>
<replacefilter token="MAINCLASS" value="${main.class}"/>
</replace>
<!-- this will preserve symlinks (that zip task cannot do) -->
<exec executable="zip" dir="${dist}.mac">
<arg value="-ry9"/>
<arg value="${ant.project.name}-mac-${version}.zip"/>
<arg value="${name}.app"/>
</exec>
<delete dir="${dist}.mac/${name}.app"/>
<delete file="${ant.project.name}-mac-${version}.jar"/>
</target>
</project>