openrocket/core/build.xml

263 lines
8.1 KiB
XML
Raw Normal View History

2009-05-31 17:23:49 +00:00
<project name="OpenRocket" basedir=".">
<property file="resources/build.properties" />
2009-06-09 16:56:52 +00:00
2009-09-01 15:25:04 +00:00
<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 -->
2009-05-31 17:23:49 +00:00
<!-- Distribution directory, from which stuff is jar'ed -->
2009-09-01 15:25:04 +00:00
<property name="dist.dir" value="${build.dir}/dist"/>
<property name="dist-test.dir" value="${build.dir}/dist-test"/>
2009-05-31 17:23:49 +00:00
<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="lib.dir" value="lib"/> <!-- Library source directory -->
2009-06-09 18:27:33 +00:00
<property name="pkgname" value="${ant.project.name}-${build.version}"/>
2009-06-09 16:56:52 +00:00
<property name="jar.file" value="${jar.dir}/${ant.project.name}.jar"/>
2009-06-09 18:27:33 +00:00
<property name="dist.bin" value="${jar.dir}/${pkgname}.jar"/>
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
2009-05-31 17:23:49 +00:00
<!-- The main class of the application -->
2009-05-31 17:50:09 +00:00
<property name="main-class" value="net.sf.openrocket.startup.Startup"/>
2009-05-31 17:23:49 +00:00
2009-09-26 17:06:37 +00:00
<!-- Classpath definitions -->
2009-05-31 17:23:49 +00:00
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
2009-09-26 17:06:37 +00:00
<path id="test-classpath">
<path refid="classpath"/>
2012-03-10 21:12:33 +00:00
<pathelement location="${basedir}/resources"/>
2009-09-26 17:06:37 +00:00
<pathelement location="${build-test.dir}"/>
<pathelement location="${classes.dir}"/>
2010-03-20 13:36:07 +00:00
<pathelement location="${src-test.dir}"/>
<fileset dir="lib-test/" includes="*.jar"/>
2009-09-26 17:06:37 +00:00
</path>
<path id="run-classpath">
<path refid="classpath"/>
<pathelement location="${basedir}/resources"/>
<pathelement location="${classes.dir}"/>
</path>
<!-- Add Ant-contrib tasks so we can use for loop -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib-extra/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
2009-09-01 15:25:04 +00:00
2009-06-09 16:56:52 +00:00
2009-05-31 17:23:49 +00:00
<!-- CLEAN -->
<target name="clean" description="Removes all build artifacts">
2009-05-31 17:23:49 +00:00
<delete dir="${build.dir}"/>
2009-09-26 17:06:37 +00:00
<delete dir="tmp/"/>
2009-05-31 17:23:49 +00:00
</target>
2009-06-09 16:56:52 +00:00
2009-05-31 17:23:49 +00:00
<!-- BUILD -->
<target name="build">
<mkdir dir="${classes.dir}"/>
2010-07-17 22:52:23 +00:00
<echo level="info">Compiling main classes</echo>
<javac debug="true" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
2009-05-31 17:23:49 +00:00
</target>
2009-06-09 16:56:52 +00:00
2009-05-31 17:23:49 +00:00
<!-- JAR -->
<target name="jar" depends="build" description="Create the OpenRocket jar file">
2009-05-31 17:23:49 +00:00
<copy todir="${dist.dir}/">
<fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
2012-03-17 20:34:44 +00:00
<fileset dir="resources/"/>
2011-08-12 19:53:00 +00:00
<fileset dir="src/" includes="META-INF/" />
2009-05-31 17:23:49 +00:00
</copy>
<mkdir dir="${jar.dir}"/>
2009-06-09 16:56:52 +00:00
<jar destfile="${jar.file}" basedir="${dist.dir}">
2009-05-31 17:23:49 +00:00
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
<attribute name="SplashScreen-Image" value="pix/splashscreen.png"/>
</manifest>
<zipfileset src="lib/miglayout15-swing.jar" />
<zipfileset src="lib/jcommon-1.0.16.jar" />
<zipfileset src="lib/jfreechart-1.0.13.jar" />
<zipfileset src="lib/iText-5.0.2.jar" />
<zipfileset src="lib/opencsv-2.3.jar" />
2012-05-22 04:11:25 +00:00
<zipfileset src="lib/exp4j-0.2.9.jar" />
2009-05-31 17:23:49 +00:00
</jar>
</target>
<!-- CONVERT vendor csv to ORC files -->
<macrodef name="build-orc-file">
<attribute name="dir"/>
<attribute name="vendor"/>
<sequential>
<echo>Generating ORC file for vendor @{vendor}</echo>
<java classname="net.sf.openrocket.preset.loader.RocksimComponentFileTranslator"
fork="true"
classpathref="run-classpath"
failonerror="true">
<arg value="@{dir}"/>
<arg value="resources/datafiles/presets/@{vendor}.orc"/>
</java>
</sequential>
</macrodef>
<target name="generate-orc-files"
description="Generate ORC file from vendor csv"
depends="build">
<for param="vendor-dir">
<dirset dir="resources-src/datafiles/rocksim_components"
includes="*"/>
<sequential>
<propertyregex property="vendor"
override="true"
input="@{vendor-dir}"
select="\1"
regexp=".*[/\\]([^/\\]*)$"/>
<build-orc-file dir="@{vendor-dir}" vendor="${vendor}"/>
</sequential>
</for>
</target>
2009-06-09 16:56:52 +00:00
<!-- DIST-SRC -->
2009-09-26 17:06:37 +00:00
<target name="dist-src">
2009-06-09 16:56:52 +00:00
<echo>
Building source distribution
</echo>
2009-06-09 18:27:33 +00:00
<mkdir dir="${build.dir}/${pkgname}"/>
2009-06-09 16:56:52 +00:00
<mkdir dir="${jar.dir}"/>
2009-06-09 18:27:33 +00:00
<copy todir="${build.dir}/${pkgname}">
2011-08-12 19:53:00 +00:00
<fileset dir="." includes="*" excludes="*.log">
2009-06-09 16:56:52 +00:00
<type type="file"/>
</fileset>
2012-03-17 20:34:44 +00:00
<fileset dir="." includes="resources/ lib/ lib-test/ src/ test/"/>
2009-06-09 18:27:33 +00:00
</copy>
<zip destfile="${dist.src}" basedir="${build.dir}" includes="${pkgname}/"/>
<delete dir="${build.dir}/${pkgname}"/>
2009-06-09 16:56:52 +00:00
</target>
<!-- DIST-SRC-TEST -->
<target name="dist-src-test" depends="dist-src">
<echo>
Testing source distribution
</echo>
2009-09-01 15:25:04 +00:00
<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}"/>
2009-06-09 16:56:52 +00:00
<echo>
2009-09-01 15:25:04 +00:00
Source distribution test successful
2009-06-09 16:56:52 +00:00
</echo>
</target>
<!-- DIST-BIN -->
2009-10-10 13:13:32 +00:00
<target name="dist-bin" depends="check,clean,unittest,jar">
2009-06-09 16:56:52 +00:00
<move file="${jar.file}" tofile="${dist.bin}"/>
2009-05-31 17:23:49 +00:00
</target>
2009-06-09 16:56:52 +00:00
<!-- 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>
2009-09-01 15:25:04 +00:00
2009-10-10 13:13:32 +00:00
<!-- CHECK -->
<target name="check" depends="checktodo,checkascii"/>
2009-09-01 15:25:04 +00:00
<!-- CHECK TODOs -->
2010-02-17 20:37:35 +00:00
<target name="todo" depends="checktodo"/>
2009-09-01 15:25:04 +00:00
<target name="checktodo">
<tempfile property="todo.file" prefix="checktodo-"/>
2011-05-14 20:21:36 +00:00
<echo>Checking project for FIXMEs.</echo>
2009-09-01 15:25:04 +00:00
<concat destfile="${todo.file}">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
2009-10-10 13:13:32 +00:00
<fileset dir="${src-test.dir}">
<include name="**/*.java"/>
</fileset>
2009-09-01 15:25:04 +00:00
<filterchain>
<linecontainsregexp>
2011-05-14 20:21:36 +00:00
<regexp pattern="(FIXME|TODO:.*CRITICAL)"/>
2009-09-01 15:25:04 +00:00
</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>
2009-10-10 13:13:32 +00:00
<!-- CHECK TODOs -->
2010-02-17 20:37:35 +00:00
<target name="ascii" depends="checkascii"/>
2009-10-10 13:13:32 +00:00
<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>
2009-09-01 15:25:04 +00:00
<!-- Unit tests -->
<target name="unittest" description="Execute unit tests" depends="build">
<echo>Building unit tests</echo>
<mkdir dir="${build-test.dir}"/>
2009-10-04 15:46:32 +00:00
<javac debug="true" srcdir="${src-test.dir}" destdir="${build-test.dir}" classpathref="test-classpath"/>
2009-09-01 15:25:04 +00:00
<echo>Running unit tests</echo>
<mkdir dir="tmp/rawtestoutput"/>
2010-03-20 13:36:07 +00:00
<junit fork="yes" forkmode="once" printsummary="false" failureproperty="junit.failure">
2009-09-26 17:06:37 +00:00
<classpath>
<path refid="test-classpath"/>
<path location="${basedir}"/>
</classpath>
2009-09-01 15:25:04 +00:00
<batchtest todir="tmp/rawtestoutput">
2009-09-26 17:06:37 +00:00
<fileset dir="${build-test.dir}">
2010-03-20 13:36:07 +00:00
<include name="**/Test*.class" />
<include name="**/*Test.class" />
2009-10-10 13:13:32 +00:00
<exclude name="**/*$*.class" />
2009-09-26 17:06:37 +00:00
<exclude name="Test.class" />
2009-09-01 15:25:04 +00:00
</fileset>
<formatter type="xml"/>
</batchtest>
</junit>
<junitreport todir="tmp">
<fileset dir="tmp/rawtestoutput"/>
<report todir="tmp/test-reports"/>
</junitreport>
2009-10-10 13:13:32 +00:00
<fail if="junit.failure" message="Unit test(s) failed. See report in ${basedir}/tmp/test-reports/index.html"/>
<echo>
Unit tests passed successfully.
</echo>
2009-09-01 15:25:04 +00:00
</target>
</project>