0.7 Release
[giyusit.git] / build.xml
bloba627cf3b4672664140ea4ed7b5479f074298b9fd
1 <project name="Giyusit" basedir="." default="run">
2         <description>
3                 Build file for Giyusit recruitment software
4         </description>
6         <property name="app.version" value="0.7" />
7         <property name="main-class" value="negev.giyusit.GiyusitApplication" />
8         
9         <!-- Input directories -->
10         <property name="src.dir" value="src" />
11         <property name="lib.dir" value="lib" />
12         <property name="resource.dir" value="resources" />
13         <property name="dist.dir" value="dist" />
14         
15         <!-- Output directories -->
16         <property name="build.dir" value="build" />
17         <property name="jar.dir" value="${build.dir}/jar" />
18         <property name="classes.dir" value="${build.dir}/classes" />
19         <property name="out.dir" value="${dist.dir}/out" />
20         <property name="jnlp.dir" value="${dist.dir}/jnlp" />
21         
22         <property name="version-file" value="${resource.dir}/giyusit.properties" />
23                 
24         <!--
25             The build file expects to find a file called build.properties in the
26             project's root directory. This file defines workstation specific 
27             properties.
28             
29             The possible properties are:
30                 launch4j.dir    The path where launch4j is installed
31                 nsisant.jar             The path to the NSIS Ant task JAR file
32                 
33                 jnlp.codebase   The URL where the Java Web Start mirror will be deployed
34                 jnlp.keystore   The key store used for signing JARs for Web Start
35                 jnlp.alias              The name of the key used for signing JARs for Web Start
36                 jnlp.storepass  The password for the key store used for signing JARs for Web Start
37         -->
38         <property file="build.properties" />
39         
40         <path id="classpath">
41                 <fileset dir="${lib.dir}" includes="**/*.jar" />
42         </path>
43         
44         <!--
45            Support targets 
46           -->
47         <condition property="version-file-available">
48                 <available file="${version-file}" />
49         </condition>
50         <target name="-generate-version-file" unless="version-file-available">
51                 <echo message="version = ${app.version}" file="${version-file}" />
52                 <echo message="Writing version file" />
53         </target>
54         
55         <!--
56            Core targets 
57           -->
58         <target name="clean" description="Deletes all intermediate generated artifacts">
59                 <delete dir="${build.dir}" />
60         </target>
61         
62         <target name="distclean" depends="clean" description="Deletes all generated artifacts">
63                 <delete dir="${out.dir}" />
64                 <delete dir="${jnlp.dir}" />
65         </target>
66         
67         <target name="compile" description="Compiles source code">
68                 <mkdir dir="${classes.dir}" />
69                 
70                 <javac srcdir="${src.dir}" 
71                                 destdir="${classes.dir}"
72                                 classpathref="classpath"
73                                 debug="true"
74                                 debuglevel="lines,vars,source" />
75                  
76                  <copy todir="${classes.dir}">
77                         <fileset dir="${src.dir}" excludes="**/*.java" />
78                  </copy>
79         </target>
80         
81         <target name="jar" depends="compile" description="Creates the application code jar">
82                 <mkdir dir="${jar.dir}" />
83                 <jar destfile="${jar.dir}/giyusit.jar" basedir="${classes.dir}">
84                         <manifest>
85                                 <attribute name="Main-Class" value="${main-class}" />
86                         </manifest>
87                 </jar>
88         </target>
89         
90         <target name="resources" 
91                         depends="-generate-version-file" 
92                         description="Creates the application resources jar">
93                 
94                 <mkdir dir="${jar.dir}" />
95                 <jar destfile="${jar.dir}/resources.jar" basedir="${resource.dir}" excludes="**/*.ts" />
96         </target>
97         
98         <!-- 
99            Run in Ant sandbox 
100           -->
101         <target name="run" depends="compile,resources" description="Runs the application inside Ant">
102                 <java fork="true" classname="${main-class}">
103                         <classpath>
104                                 <path refid="classpath" />
105                                 <path location="${classes.dir}" />
106                                 <path location="${jar.dir}/resources.jar" />
107                         </classpath>
108                 </java>
109         </target>
110         
111         <!--
112            Targets for deploying as a stand-alone EXE file
113           -->
114         <target name="-uber-jar" depends="jar,resources">
115                 <!-- Merge the application, resource and library jars into a single one -->
116                 <jar destfile="${jar.dir}/giyusit-uber.jar">
117                         <zipfileset src="${jar.dir}/giyusit.jar" />
118                         <zipfileset src="${jar.dir}/resources.jar" />
119                         <zipgroupfileset dir="${lib.dir}" includes="*.jar" />
120                         
121                         <manifest>
122                                 <attribute name="Main-Class" value="${main-class}" />
123                         </manifest>
124                 </jar>
125         </target>
126         
127         <target name="exe" depends="-uber-jar" description="Generates a Windows executable">
128                 <taskdef name="launch4j" 
129                                 classname="net.sf.launch4j.ant.Launch4jTask" 
130                                 classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" />
131                 
132                 <mkdir dir="${out.dir}" />
133                 
134                 <launch4j configFile="${dist.dir}/launch4j.xml" 
135                                 jar="${jar.dir}/giyusit-uber.jar"
136                                 outfile="${out.dir}/Giyusit.exe" />
137         </target>
138         
139         <target name="installer" depends="exe" description="Generates a Windows installer">
140                 <taskdef name="nsis" 
141                                 classname="net.sf.nsisant.Task" 
142                                 classpath="${nsisant.jar}"/>
143                 
144                 <nsis script="${dist.dir}/installer.nsi">
145                         <define name="VERSION" value="${app.version}" />
146                 </nsis>
147         </target>
148         
149         <!-- 
150            Targets for deploying using Java Web Start
151           -->
152         <target name="-lib-jar">
153                 <!-- Merges library jars into a single one -->
154                 <jar destfile="${jar.dir}/giyusit-libs.jar">
155                         <zipgroupfileset dir="${lib.dir}" includes="*.jar" />
156                 </jar>
157         </target>
158         
159         <target name="jnlp" depends="jar,resources,-lib-jar" description="Generate Java Web Start site mirror">
160                 <mkdir dir="${jnlp.dir}" />
161                 
162                 <!-- Prepare JNLP file -->
163                 <property name="jnlp.file" value="${jnlp.dir}/Giyusit.jnlp" />
164                 
165                 <copy file="${dist.dir}/Giyusit.jnlp.in" tofile="${jnlp.file}" />
166                 <replace file="${jnlp.file}" token="@codebase@" value="${jnlp.codebase}" />
167                 <replace file="${jnlp.file}" token="@version@" value="${app.version}" />
168                 <replace file="${jnlp.file}" token="@main-class@" value="${main-class}" />
169                 
170                 <!-- Copy and sign application JARs -->
171                 <signjar destDir="${jnlp.dir}" 
172                                         keystore="${jnlp.keystore}"
173                                         alias="${jnlp.alias}" 
174                                         storepass="${jnlp.storepass}">
175                         <path>
176                                 <fileset file="${jar.dir}/giyusit.jar" />
177                                 <fileset file="${jar.dir}/resources.jar" />
178                                 <fileset file="${jar.dir}/giyusit-libs.jar" />
179                         </path>
180                 </signjar>
181                 
182                 <!-- Copy helper files -->
183                 <copy file="${dist.dir}/index.html" todir="${jnlp.dir}" />
184                 
185                 <echo message="Java Web Start mirror ready in: ${basedir}/${jnlp.dir}" />
186         </target>
187 </project>