| 1 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| 2 | |
|---|
| 3 | <project name="JErgometer" default="runJErgometer" basedir="."> |
|---|
| 4 | <!-- Overwrite default variables in this file --> |
|---|
| 5 | <property file="build.properties" /> |
|---|
| 6 | |
|---|
| 7 | <!-- Update if needed. --> |
|---|
| 8 | <property name="program.version" value="0.8"/> |
|---|
| 9 | |
|---|
| 10 | <!-- Main class. --> |
|---|
| 11 | <property name="main.class" value="org.jergometer.Jergometer"/> |
|---|
| 12 | |
|---|
| 13 | <!-- File names. --> |
|---|
| 14 | <property name="start.sh" value="jergometer"/> |
|---|
| 15 | <property name="start.bat" value="jergometer.bat"/> |
|---|
| 16 | <property name="program.jar" value="jergometer.jar"/> |
|---|
| 17 | |
|---|
| 18 | <!-- Locations --> |
|---|
| 19 | <property name="src" location="src"/> |
|---|
| 20 | <property name="src-test" location="test/src"/> |
|---|
| 21 | <property name="build" location="build"/> |
|---|
| 22 | <property name="lib" value="lib"/> |
|---|
| 23 | <property name="dist" location="dist"/> |
|---|
| 24 | <property name="upload" location="${dist}/${ant.project.name}"/> |
|---|
| 25 | <property name="uploadPrepare" location="${dist}/${ant.project.name}_prepare"/> |
|---|
| 26 | <property name="linuxSrcPkg" location="${dist}/jergometer"/> |
|---|
| 27 | <property name="releases" location="${dist}/releases"/> |
|---|
| 28 | |
|---|
| 29 | <property name="buildClasses" location="${build}/classes"/> |
|---|
| 30 | <property name="buildClasses-test" location="${build}/classes-test"/> |
|---|
| 31 | <property name="programJar" location="${uploadPrepare}/${program.jar}"/> |
|---|
| 32 | <property name="velocityJar" value="${lib}/velocity-1.7-dep.jar"/> |
|---|
| 33 | <property name="rxtxJar" value="${lib}/RXTXcomm.jar"/> |
|---|
| 34 | <property name="rxtxSoDir" location="."/> |
|---|
| 35 | |
|---|
| 36 | <path id="libraries"> |
|---|
| 37 | <fileset dir="${lib}"> |
|---|
| 38 | <include name="*.jar"/> |
|---|
| 39 | </fileset> |
|---|
| 40 | <filelist> |
|---|
| 41 | <file name="${velocityJar}"/> |
|---|
| 42 | <file name="${rxtxJar}"/> |
|---|
| 43 | </filelist> |
|---|
| 44 | </path> |
|---|
| 45 | |
|---|
| 46 | <path id="libraries-test"> |
|---|
| 47 | <fileset dir="test/lib"> |
|---|
| 48 | <include name="*.jar"/> |
|---|
| 49 | </fileset> |
|---|
| 50 | </path> |
|---|
| 51 | |
|---|
| 52 | <target name="osInfo"> |
|---|
| 53 | <echo message="os.name: ${os.name}"/> |
|---|
| 54 | <echo message="os.arch: ${os.arch}"/> |
|---|
| 55 | <echo message="os.version: ${os.version}"/> |
|---|
| 56 | </target> |
|---|
| 57 | |
|---|
| 58 | <!-- Run application. --> |
|---|
| 59 | <target name="runJErgometer" depends="osInfo,compile"> |
|---|
| 60 | <java classname="${main.class}" fork="true"> |
|---|
| 61 | <classpath> |
|---|
| 62 | <pathelement location="${buildClasses}" /> |
|---|
| 63 | <path refid="libraries"/> |
|---|
| 64 | </classpath> |
|---|
| 65 | <jvmarg value="-Djava.library.path=${lib}/dlls/${os.name}/${os.arch}" /> |
|---|
| 66 | <!-- <jvmarg value="-Djava.util.logging.config.file=conf/logging.properties" />--> |
|---|
| 67 | <arg value="--bleeding-edge"/> |
|---|
| 68 | </java> |
|---|
| 69 | </target> |
|---|
| 70 | |
|---|
| 71 | <!-- Delete class and jar files. --> |
|---|
| 72 | <target name="clean"> |
|---|
| 73 | <delete dir="${buildClasses}"/> |
|---|
| 74 | <delete file="${programJar}"/> |
|---|
| 75 | <delete dir="${build}"/> |
|---|
| 76 | </target> |
|---|
| 77 | |
|---|
| 78 | <!-- Compile application. --> |
|---|
| 79 | <target name="compile"> |
|---|
| 80 | <mkdir dir="${buildClasses}"/> |
|---|
| 81 | |
|---|
| 82 | <!-- Compile the project. --> |
|---|
| 83 | <javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on"> |
|---|
| 84 | <classpath> |
|---|
| 85 | <pathelement location="${buildClasses}" /> |
|---|
| 86 | <path refid="libraries"/> |
|---|
| 87 | </classpath> |
|---|
| 88 | </javac> |
|---|
| 89 | |
|---|
| 90 | <!-- Copy all non-java files to classes. --> |
|---|
| 91 | <copy todir="${buildClasses}"> |
|---|
| 92 | <fileset dir="src"> |
|---|
| 93 | <exclude name="**/*.java"/> |
|---|
| 94 | </fileset> |
|---|
| 95 | </copy> |
|---|
| 96 | </target> |
|---|
| 97 | |
|---|
| 98 | <!-- Compile application. --> |
|---|
| 99 | <target name="compile-test" depends="compile"> |
|---|
| 100 | <mkdir dir="${buildClasses-test}"/> |
|---|
| 101 | |
|---|
| 102 | <!-- Compile the project. --> |
|---|
| 103 | <javac srcdir="${src-test}" destdir="${buildClasses-test}" target="1.5" source="1.5" encoding="UTF-8" debug="on"> |
|---|
| 104 | <classpath> |
|---|
| 105 | <pathelement location="${buildClasses}"/> |
|---|
| 106 | <pathelement location="${buildClasses-test}"/> |
|---|
| 107 | <path refid="libraries"/> |
|---|
| 108 | <path refid="libraries-test"/> |
|---|
| 109 | </classpath> |
|---|
| 110 | </javac> |
|---|
| 111 | </target> |
|---|
| 112 | |
|---|
| 113 | <!-- Run tests. --> |
|---|
| 114 | <target name="test" depends="compile-test"> |
|---|
| 115 | <junit> |
|---|
| 116 | <classpath> |
|---|
| 117 | <pathelement location="${buildClasses}"/> |
|---|
| 118 | <pathelement location="${buildClasses-test}"/> |
|---|
| 119 | <path refid="libraries"/> |
|---|
| 120 | <path refid="libraries-test"/> |
|---|
| 121 | </classpath> |
|---|
| 122 | |
|---|
| 123 | <formatter type="brief" usefile="false" /> |
|---|
| 124 | <batchtest> |
|---|
| 125 | <fileset dir="${buildClasses-test}" includes="**/*Test.class" /> |
|---|
| 126 | </batchtest> |
|---|
| 127 | </junit> |
|---|
| 128 | </target> |
|---|
| 129 | |
|---|
| 130 | <!-- Builds the upload directory including the jar file. --> |
|---|
| 131 | <target name="jar" depends="compile,updateBuildNumber"> |
|---|
| 132 | <delete dir="${uploadPrepare}"/> |
|---|
| 133 | <mkdir dir="${uploadPrepare}"/> |
|---|
| 134 | |
|---|
| 135 | <!-- Build jar file. --> |
|---|
| 136 | <jar jarfile="${programJar}" basedir="${buildClasses}"> |
|---|
| 137 | <manifest> |
|---|
| 138 | <attribute name="Main-Class" value="${main.class}"/> |
|---|
| 139 | </manifest> |
|---|
| 140 | </jar> |
|---|
| 141 | |
|---|
| 142 | <!-- Copy example programs and dlls. --> |
|---|
| 143 | <copy todir="${uploadPrepare}/programs"> |
|---|
| 144 | <fileset dir="programs"/> |
|---|
| 145 | </copy> |
|---|
| 146 | <mkdir dir="${uploadPrepare}/lib"/> |
|---|
| 147 | <copy todir="${uploadPrepare}/lib"> |
|---|
| 148 | <fileset dir="${lib}"> |
|---|
| 149 | <include name="*.jar"/> |
|---|
| 150 | <exclude name="annotations.jar"/> |
|---|
| 151 | </fileset> |
|---|
| 152 | </copy> |
|---|
| 153 | <copy todir="${uploadPrepare}/lib/dlls"> |
|---|
| 154 | <fileset dir="${lib}/dlls"/> |
|---|
| 155 | </copy> |
|---|
| 156 | |
|---|
| 157 | <!-- Copy start scripts. --> |
|---|
| 158 | <copy todir="${uploadPrepare}" file="scripts/${start.sh}"/> |
|---|
| 159 | <copy todir="${uploadPrepare}" file="scripts/${start.bat}"/> |
|---|
| 160 | <copy todir="${uploadPrepare}/start"> |
|---|
| 161 | <fileset dir="scripts/start"/> |
|---|
| 162 | </copy> |
|---|
| 163 | <chmod file="${uploadPrepare}/${start.sh}" perm="ugo+x"/> |
|---|
| 164 | <chmod file="${uploadPrepare}/start/unix_start.sh" perm="ugo+x"/> |
|---|
| 165 | </target> |
|---|
| 166 | |
|---|
| 167 | <!-- Build a new release version. --> |
|---|
| 168 | <target name="create_release" depends="jar,create_linux_source_package"> |
|---|
| 169 | <mkdir dir="${releases}"/> |
|---|
| 170 | |
|---|
| 171 | <exec executable="scripts/create_release"> |
|---|
| 172 | <arg value="${program.version}.${build.number}"/> |
|---|
| 173 | </exec> |
|---|
| 174 | </target> |
|---|
| 175 | |
|---|
| 176 | <!-- Increments the build number. --> |
|---|
| 177 | <target name="updateBuildNumber"> |
|---|
| 178 | <exec executable="scripts/check_version"> |
|---|
| 179 | <arg value="${program.version}"/> |
|---|
| 180 | </exec> |
|---|
| 181 | |
|---|
| 182 | <buildnumber/> |
|---|
| 183 | |
|---|
| 184 | <echo message="${program.version}.${build.number}" file="${buildClasses}/version.txt"/> |
|---|
| 185 | </target> |
|---|
| 186 | |
|---|
| 187 | <!-- Validates the source code and creates a new release on the remote server. --> |
|---|
| 188 | <target name="create_remote_release" depends="compile"> |
|---|
| 189 | <exec executable="scripts/create_remote_release"> |
|---|
| 190 | <arg value="${ant.project.name}-${program.version}.${build.number}"/> |
|---|
| 191 | </exec> |
|---|
| 192 | </target> |
|---|
| 193 | |
|---|
| 194 | <!-- Build the Linux source package. --> |
|---|
| 195 | <target name="create_linux_source_package" depends="jar"> |
|---|
| 196 | <delete dir="${linuxSrcPkg}-${program.version}.${build.number}"/> |
|---|
| 197 | <mkdir dir="${linuxSrcPkg}-${program.version}.${build.number}"/> |
|---|
| 198 | <copy todir="${linuxSrcPkg}-${program.version}.${build.number}"> |
|---|
| 199 | <fileset dir="."> |
|---|
| 200 | <include name="lib/annotations.jar"/> |
|---|
| 201 | <include name="lib/velocity-1.7-dep.jar"/> |
|---|
| 202 | <include name="programs/**"/> |
|---|
| 203 | <include name="scripts/create_linux_source_package"/> |
|---|
| 204 | <include name="src/**"/> |
|---|
| 205 | <include name="build.xml"/> |
|---|
| 206 | <include name="CHANGELOG"/> |
|---|
| 207 | <include name="COPYING"/> |
|---|
| 208 | </fileset> |
|---|
| 209 | <fileset dir="packaging/linux"> |
|---|
| 210 | <include name="**"/> |
|---|
| 211 | </fileset> |
|---|
| 212 | </copy> |
|---|
| 213 | <copy todir="${linuxSrcPkg}-${program.version}.${build.number}/src"> |
|---|
| 214 | <fileset dir="${buildClasses}"> |
|---|
| 215 | <include name="version.txt"/> |
|---|
| 216 | </fileset> |
|---|
| 217 | </copy> |
|---|
| 218 | <chmod file="${linuxSrcPkg}-${program.version}.${build.number}/configure" perm="ugo+x"/> |
|---|
| 219 | <chmod file="${linuxSrcPkg}-${program.version}.${build.number}/scripts/*" perm="ugo+x"/> |
|---|
| 220 | |
|---|
| 221 | <exec executable="scripts/create_linux_source_package" dir="."> |
|---|
| 222 | <arg value="${program.version}.${build.number}"/> |
|---|
| 223 | </exec> |
|---|
| 224 | </target> |
|---|
| 225 | |
|---|
| 226 | <!-- Build the Linux package. --> |
|---|
| 227 | <target name="create_linux_package" depends="linux_jar"> |
|---|
| 228 | </target> |
|---|
| 229 | |
|---|
| 230 | <!-- Builds the upload directory including the jar file. --> |
|---|
| 231 | <target name="linux_jar" depends="compile"> |
|---|
| 232 | <delete dir="${uploadPrepare}"/> |
|---|
| 233 | <mkdir dir="${uploadPrepare}"/> |
|---|
| 234 | |
|---|
| 235 | <!-- Build jar file. --> |
|---|
| 236 | <echo message="false" file="${buildClasses}/updatable"/> |
|---|
| 237 | <jar jarfile="${programJar}" basedir="${buildClasses}"> |
|---|
| 238 | <manifest> |
|---|
| 239 | <attribute name="Main-Class" value="${main.class}"/> |
|---|
| 240 | <attribute name="Class-Path" value="${velocityJar}"/> |
|---|
| 241 | <attribute name="Class-Path" value="${rxtxJar}"/> |
|---|
| 242 | </manifest> |
|---|
| 243 | </jar> |
|---|
| 244 | |
|---|
| 245 | <!-- Copy example programs and dlls. --> |
|---|
| 246 | <copy todir="${uploadPrepare}/programs"> |
|---|
| 247 | <fileset dir="programs"/> |
|---|
| 248 | </copy> |
|---|
| 249 | |
|---|
| 250 | <!-- Copy start scripts. --> |
|---|
| 251 | <copy todir="${uploadPrepare}" file="scripts/${start.sh}"> |
|---|
| 252 | <filterset> |
|---|
| 253 | <filter token="velocityJar" value="${velocityJar}"/> |
|---|
| 254 | <filter token="rxtxJar" value="${rxtxJar}"/> |
|---|
| 255 | <filter token="rxtxSoDir" value="${rxtxSoDir}"/> |
|---|
| 256 | </filterset> |
|---|
| 257 | </copy> |
|---|
| 258 | <copy todir="${uploadPrepare}/start"> |
|---|
| 259 | <fileset dir="scripts/start"/> |
|---|
| 260 | </copy> |
|---|
| 261 | <chmod file="${uploadPrepare}/${start.sh}" perm="ugo+x"/> |
|---|
| 262 | <chmod file="${uploadPrepare}/start/unix_start.sh" perm="ugo+x"/> |
|---|
| 263 | </target> |
|---|
| 264 | </project> |
|---|