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
|
<project name="OpenRocket" basedir=".">
<property file="resources/build.properties" />
<property name="src.dir" value="src"/> <!-- Source directory -->
<property name="src-test.dir" value="test"/> <!-- Test directory -->
<property name="build.dir" value="build"/> <!-- Build directory -->
<property name="build-test.dir" value="build/test"/><!-- Build directory -->
<!-- Distribution directory, from which stuff is jar'ed -->
<property name="dist.dir" value="${build.dir}/dist"/>
<property name="dist-test.dir" value="${build.dir}/dist-test"/>
<property name="classes.dir" value="${dist.dir}"/> <!-- Directory for classes -->
<property name="jar.dir" value="${build.dir}/jar"/> <!-- Directory for built jar's -->
<property name="pkgname" value="${ant.project.name}-${build.version}"/>
<property name="jar.file" value="${jar.dir}/${ant.project.name}.jar"/>
<property name="dist.bin" value="${jar.dir}/${pkgname}.jar"/>
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
<!-- The main class of the application -->
<property name="main-class" value="net.sf.openrocket.startup.Startup"/>
<!-- Classpath definitions -->
<path id="classpath">
<!-- update manifest class-path definition below too when making changes here -->
<pathelement location="/usr/share/java/itext5.jar"/>
<pathelement location="/usr/share/java/jcommon.jar"/>
<pathelement location="/usr/share/java/jfreechart.jar"/>
<pathelement location="/usr/share/java/jmock2.jar"/>
<pathelement location="/usr/share/java/miglayout.jar"/>
</path>
<path id="test-classpath">
<path refid="classpath"/>
<pathelement location="${basedir}/resources"/>
<pathelement location="${build-test.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${src-test.dir}"/>
<pathelement location="/usr/share/java/junit4.jar"/>
</path>
<!-- CLEAN -->
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="tmp/"/>
</target>
<!-- BUILD -->
<target name="build">
<mkdir dir="${classes.dir}"/>
<echo level="info">Compiling main classes</echo>
<javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>
<!-- JAR -->
<target name="jar" depends="build">
<copy todir="${dist.dir}/">
<fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
<fileset dir="resources/"/>
<fileset dir="src/" includes="META-INF/" />
</copy>
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.file}" basedir="${dist.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
<attribute name="Class-Path" value="/usr/share/java/jcommon.jar /usr/share/java/jfreechart.jar /usr/share/java/miglayout.jar /usr/share/java/itext5.jar"/>
</manifest>
</jar>
</target>
<!-- DIST-SRC -->
<target name="dist-src">
<echo>
Building source distribution
</echo>
<mkdir dir="${build.dir}/${pkgname}"/>
<mkdir dir="${jar.dir}"/>
<copy todir="${build.dir}/${pkgname}">
<fileset dir="." includes="*" excludes="*.log">
<type type="file"/>
</fileset>
<fileset dir="." includes="resources/ src/ test/"/>
</copy>
<zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
<delete dir="${build.dir}/${pkgname}"/>
</target>
<!-- DIST-SRC-TEST -->
<target name="dist-src-test" depends="dist-src">
<echo>
Testing source distribution
</echo>
<delete dir="${dist-test.dir}"/>
<mkdir dir="${dist-test.dir}"/>
<unzip dest="${dist-test.dir}" src="${dist.src}"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="jar"/>
<ant dir="${dist-test.dir}/${pkgname}" antfile="build.xml" target="unittest"/>
<delete dir="${dist-test.dir}"/>
<echo>
Source distribution test successful
</echo>
</target>
<!-- DIST-BIN -->
<target name="dist-bin" depends="check,clean,jar">
<move file="${jar.file}" tofile="${dist.bin}"/>
</target>
<!-- DIST -->
<target name="dist" depends="dist-bin,dist-src,dist-src-test">
<echo>Distribution ${build.version} (${build.source}) built into directory ${jar.dir}</echo>
</target>
<!-- CHECK -->
<target name="check" depends="checktodo,checkascii"/>
<!-- CHECK TODOs -->
<target name="todo" depends="checktodo"/>
<target name="checktodo">
<tempfile property="todo.file" prefix="checktodo-"/>
<echo>Checking project for FIXMEs.</echo>
<concat destfile="${todo.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${todo.file}" property="criticaltodos"/>
<delete file="${todo.file}"/>
<fail if="criticaltodos">CRITICAL TODOs exist in project:
${criticaltodos}</fail>
<echo>No critical TODOs in project.</echo>
</target>
<!-- CHECK TODOs -->
<target name="ascii" depends="checkascii"/>
<target name="checkascii">
<tempfile property="ascii.file" prefix="checkascii-"/>
<echo>Checking project for non-ASCII characters.</echo>
<concat destfile="${ascii.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
<filterchain>
<linecontainsregexp>
<regexp pattern="\P{ASCII}"/>
</linecontainsregexp>
</filterchain>
</concat>
<loadfile srcfile="${ascii.file}" property="nonascii"/>
<delete file="${ascii.file}"/>
<fail if="nonascii">Non-ASCII characters exist in project:
${nonascii}</fail>
<echo>No non-ASCII characters in project.</echo>
</target>
<!-- Unit tests -->
<target name="unittest" description="Execute unit tests" depends="build">
<echo>Building unit tests</echo>
<mkdir dir="${build-test.dir}"/>
<javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
<echo>Running unit tests</echo>
<mkdir dir="tmp/rawtestoutput"/>
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
<classpath>
<path refid="test-classpath"/>
<path location="${basedir}"/>
</classpath>
<batchtest todir="tmp/rawtestoutput">
<fileset dir="${build-test.dir}">
<include name="**/Test*.class" />
<include name="**/*Test.class" />
<exclude name="**/*$*.class" />
<exclude name="Test.class" />
</fileset>
<formatter type="xml"/>
</batchtest>
</junit>
<junitreport todir="tmp">
<fileset dir="tmp/rawtestoutput"/>
<report todir="tmp/test-reports"/>
</junitreport>
<fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
<echo>
Unit tests passed successfully.
</echo>
</target>
</project>
|