Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / build.xml
index 0e57a6b0cdc212dd0c3a243347f5b4be40a5238c..9b178defe66a59021edbec0287b652ba09fdaa0a 100644 (file)
                <pathelement location="${src-test.dir}"/>
                <fileset dir="lib-test/" includes="*.jar"/>
        </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>
 
        
        <!-- CLEAN -->
-       <target name="clean">
+       <target name="clean" description="Removes all build artifacts">
                <delete dir="${build.dir}"/>
                <delete dir="tmp/"/>
        </target>
                <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/"/>
+       <!-- Executible Eclipse-Jar-In-Jar style JAR -->
+       <target name="jar" depends="core-jar" description="Create the OpenRocket jar-in-jar Executable">
+               <mkdir dir="${jar.dir}" />
+               <jar destfile="${jar.file}">
+                       <manifest>
+                               <attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader" />
+                               <attribute name="Rsrc-Main-Class" value="${main-class}" />
+                               <attribute name="SplashScreen-Image" value="pix/splashscreen.png" />
+                               <attribute name="Class-Path" value="." />
+                               <attribute name="Rsrc-Class-Path" value="./ main/${ant.project.name}-Core.jar lib/jfreechart-1.0.13.jar lib/jcommon-1.0.16.jar lib/gluegen-rt.jar lib/miglayout15-swing.jar lib/iText-5.0.2.jar lib/jogl.all.jar lib/opencsv-2.3.jar lib/OrangeExtensions-1.2.jar" />
+                       </manifest>
+
+                       <!-- Unzip the Eclipse JIJ Loader -->
+                       <zipfileset src="lib/jar-in-jar-loader.jar" />
+                       
+                       <!-- Include, in the root of the JAR, the resources needed by OR -->
                        <fileset dir="src/" includes="META-INF/" />
-               </copy>
-               <mkdir dir="${jar.dir}"/>
-               <jar destfile="${jar.file}" basedir="${dist.dir}">
+                       <fileset dir="resources/" />
+                       
+                       <!-- Include the core OpenRocket JAR -->
+                       <zipfileset dir="${build.dir}/" prefix="main">
+                               <include name="${ant.project.name}-Core.jar"/>
+                       </zipfileset>
+                       
+                       <!-- Include libraries needed by OR -->
+                       <zipfileset dir="${lib.dir}" prefix="lib">
+                               <include name="*.jar"/>
+                       </zipfileset>
+                       <zipfileset dir="${lib.dir}/jogl" prefix="lib">
+                               <include name="*.jar"/>
+                       </zipfileset>
+                       
+                       <!-- Include metafiles about OR -->
+                       <fileset dir="." includes="LICENSE.TXT README.TXT ChangeLog ReleaseNotes fileformat.txt" />
+               </jar>
+       </target>
+       
+       
+       <!-- Core OpenRocket JAR -->
+       <target name="core-jar" depends="build" description="Create the OpenRocket code-only jar file">
+               <jar destfile="${build.dir}/${ant.project.name}-Core.jar" basedir="${dist.dir}">
                        <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" />
                </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>
        
        <!-- DIST-SRC -->
        <target name="dist-src">
@@ -212,4 +284,4 @@ ${nonascii}</fail>
                </echo>
        </target>
     
-</project>
\ No newline at end of file
+</project>