Merge pull request #262 from psxlover/Build.xml

Build.xml
This commit is contained in:
SirSengir 2012-09-14 05:37:57 -07:00
commit 0fa5a9d38e
3 changed files with 194 additions and 112 deletions

View file

@ -12,10 +12,11 @@ features or change existing behaivour, please discuss it with Sengir or Krapht b
1. Ensure that `Apache Ant` (found [here](http://ant.apache.org/)) is installed correctly on your system. 1. Ensure that `Apache Ant` (found [here](http://ant.apache.org/)) is installed correctly on your system.
* Linux users will need the latest version of astyle installed as well. * Linux users will need the latest version of astyle installed as well.
1. Create a base directory for the build 1. Create a base directory for the build
1. Clone the Buildcraft repository into `basedir/src/` 1. Clone the Buildcraft repository into `basedir/BuildCraft/`
* Optional: Copy BuildCraft localization repository into `basedir/BuildCraft-Localization`
1. Copy the minecraft bin dir and minecraft_server.jar into `basedir/jars/` 1. Copy the minecraft bin dir and minecraft_server.jar into `basedir/jars/`
1. Navigate to basedir/src in a shell and run `ant clean package` (this will take 2-5 minutes) 1. Navigate to basedir/Buildcraft in a shell and run `ant` (this will take 2-5 minutes)
1. The compiled and obfuscated jars will be in basedir/build/dist 1. The compiled and obfuscated jar will be in basedir/build/dist
Your directory structure should look like this: Your directory structure should look like this:
*** ***
@ -26,10 +27,12 @@ Your directory structure should look like this:
\- bin \- bin
|- minecraft.jar |- minecraft.jar
|- ... |- ...
\- src \- BuildCraft
|- buildcraft_client |- buildcraft_resources
|- buildcraft_server |- common
|- ... |- ...
\- BuildCraft-Localization
|- lang
*** ***

279
build.xml
View file

@ -1,136 +1,215 @@
<project name="Buildcraft" basedir="../" default="main"> <project name="Buildcraft" basedir="../" default="main">
<taskdef resource="net/sf/antcontrib/antlib.xml"> <property environment="env" />
<classpath> <!-- Properties -->
<pathelement location="contrib/ant-contrib.jar"/>
<pathelement location="contrib/commons-httpclient.jar"/>
<pathelement location="/usr/share/java/ant-contrib.jar"/>
<pathelement location="/usr/share/java/commons-httpclient.jar"/>
</classpath>
</taskdef>
<property environment="env" />
<!-- Properties -->
<property name="build.dir" value="build"/> <property name="build.dir" value="build"/>
<property name="src.dir" value="src"/> <property name="src.dir" value="BuildCraft"/>
<property name="lang.dir" value="BuildCraft-Localization"/>
<property name="download.dir" value="download"/> <property name="download.dir" value="download"/>
<property name="files.minecraft.dir" value="jars"/> <property name="files.minecraft.dir" value="jars"/>
<property name="classes.dir" value="${build.dir}/classes"/> <property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/dist"/> <property name="jar.dir" value="${build.dir}/dist"/>
<property name="mcp.dir" value="${build.dir}/mcp"/> <property name="mcp.dir" value="${build.dir}/mcp"/>
<property name="forge.dir" value="${mcp.dir}/forge"/> <property name="forge.dir" value="${mcp.dir}/forge"/>
<property name="clientsrc.dir" value="${mcp.dir}/src/minecraft"/> <property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft"/>
<property name="mcp.version" value="72"/> <property name="mcp.version" value="72"/>
<property name="forge.version" value="4.0.0.232"/> <property name="forge.version" value="4.0.0.232"/>
<property name="bc.version" value="3.1.8"/> <property name="bc.version" value="3.1.8"/>
<property name="bc.version.full" value="${bc.version}.${env.BUILD_NUMBER}"/>
<echo message="Starting build for ${bc.version.full}"/> <available property="forge-exists" file="${download.dir}/minecraftforge-src-${forge.version}.zip"/>
<condition property="should-download-ant-contrib">
<or>
<available file="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
<available file="${download.dir}/minecraftforge-src-${forge.version}.zip"/>
</or>
</condition>
<!-- Targets -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<target name="setup"> <mkdir dir="${download.dir}"/>
<mkdir dir="${download.dir}"/> <!-- Targets -->
<get src="http://mcp.ocean-labs.de/files/mcp${mcp.version}.zip" dest="${download.dir}" usetimestamp="True"/> <target name="clean">
<getMethod url="http://files.minecraftforge.net/minecraftforge-src-${forge.version}.zip" <delete dir="${build.dir}"/>
responseDataFile="${download.dir}/minecraftforge-src-${forge.version}.zip"> </target>
<header name="User-Agent" value="Ant-${ant.version}/${ant.java.version}" />
</getMethod>
<unzip dest="${mcp.dir}"> <!-- Set build number -->
<fileset dir="${download.dir}"> <target name="initialize-version" depends="version-provided,version-not-provided">
<include name="mcp*.zip"/> <property name="bc.version.full" value="${bc.version}.${build.number}"/>
</fileset> <echo message="Starting build for ${bc.version.full}"/>
</unzip> </target>
<unzip dest="${mcp.dir}"> <target name="version-not-provided" unless="env.BUILD_NUMBER">
<fileset dir="${download.dir}"> <buildnumber/>
<include name="minecraftforge-src-*.zip"/> </target>
</fileset>
</unzip>
<copy todir="${mcp.dir}/jars"> <target name="version-provided" if="env.BUILD_NUMBER">
<fileset dir="${files.minecraft.dir}"/> <property name="build.number" value="${env.BUILD_NUMBER}"/>
</copy> </target>
<chmod file="${mcp.dir}/updatemd5.sh" perm="+x"/> <!-- Download necessary files -->
<chmod file="${mcp.dir}/recompile.sh" perm="+x"/> <target name="download-files" depends="download-mcp,download-forge"/>
<chmod file="${mcp.dir}/reobfuscate.sh" perm="+x"/>
<chmod file="${forge.dir}/install.sh" perm="+x"/>
<!-- if your building on OSX these 2 should be executable --> <!-- Download ant-contrib, necessary to be able to download forge (only if neither forge zip nor ant-contrib exist) -->
<chmod file="${mcp.dir}/runtime/bin/astyle-osx" perm="+x" /> <target name="download-ant-contrib" unless="should-download-ant-contrib">
<chmod file="${mcp.dir}/runtime/bin/jad-osx" perm="+x" />
<!-- Install forge --> <echo message="Getting: ant-contrib"/>
<exec dir="${forge.dir}" executable="cmd" osfamily="windows"> <mkdir dir="${download.dir}/tmp"/>
<arg line="/c install.cmd"/>
</exec>
<exec dir="${forge.dir}" executable="sh" osfamily="unix"> <get src="http://sourceforge.net/projects/ant-contrib/files/ant-contrib/1.0b3/ant-contrib-1.0b3-bin.zip/download" dest="${download.dir}/tmp/ant-contrib-1.0b3-bin.zip"/>
<arg value="install.sh" /> <get src="http://apache.cc.uoc.gr/commons/codec/binaries/commons-codec-1.6-bin.zip" dest="${download.dir}/tmp/commons-codec-1.6-bin.zip"/>
</exec>
<!-- Copy BC source --> <unzip src="${download.dir}/tmp/ant-contrib-1.0b3-bin.zip" dest="${download.dir}"/>
<copy todir="${clientsrc.dir}"> <unzip src="${download.dir}/tmp/commons-codec-1.6-bin.zip" dest="${download.dir}/tmp"/>
<fileset dir="${src.dir}/common">
<exclude name="**/buildcraft/devel"/>
</fileset>
<filterset>
<filter token="VERSION" value="${bc.version}" />
</filterset>
</copy>
</target> <move todir="${download.dir}/ant-contrib/lib">
<fileset file="${download.dir}/tmp/commons-codec-1.6/commons-codec-1.6.jar"/>
</move>
<target name="compile" depends="setup"> <!-- Delete useless files -->
<delete dir="${download.dir}/ant-contrib/docs"/>
<delete dir="${download.dir}/tmp"/>
<!-- Recompile --> </target>
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c recompile.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix"> <!-- Download mcp -->
<arg value="recompile.sh" /> <target name="download-mcp">
</exec>
<!-- Reobf --> <get src="http://mcp.ocean-labs.de/files/mcp${mcp.version}.zip" dest="${download.dir}" usetimestamp="True"/>
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix"> </target>
<arg value="reobfuscate.sh" />
</exec>
<!-- Copy BC classes --> <!-- Download forge (if it doesn't exist) -->
<copy todir="${classes.dir}/client"> <target name="download-forge" depends="download-ant-contrib" unless="forge-exists" >
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
<!-- Copy resoucres --> <taskdef resource="net/sf/antcontrib/antlib.xml">
<copy todir="${classes.dir}/client"> <classpath>
<fileset dir="${src.dir}/buildcraft_resources"/> <pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
</copy> <fileset dir="${download.dir}/ant-contrib/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
</target> <getMethod url="http://files.minecraftforge.net/minecraftforge-src-${forge.version}.zip"
responseDataFile="${download.dir}/minecraftforge-src-${forge.version}.zip">
<header name="User-Agent" value="Ant-${ant.version}/${ant.java.version}"/>
</getMethod>
<target name="package" depends="compile"> </target>
<jar destfile="${jar.dir}/buildcraft-A-${bc.version.full}.jar" basedir="${classes.dir}/client"/> <!-- Setup mcp and forge -->
<target name="setup" depends="initialize-version">
</target> <!-- Unzip them -->
<unzip dest="${mcp.dir}">
<fileset dir="${download.dir}">
<include name="mcp${mcp.version}.zip"/>
</fileset>
</unzip>
<target name="main" depends="clean,package"/> <unzip dest="${mcp.dir}">
<fileset dir="${download.dir}">
<include name="minecraftforge-src-${forge.version}.zip"/>
</fileset>
</unzip>
<!-- Copy the necessary jars -->
<copy todir="${mcp.dir}/jars">
<fileset dir="${files.minecraft.dir}"/>
</copy>
<!-- Change executables' permitions -->
<chmod file="${mcp.dir}/updatemd5.sh" perm="+x"/>
<chmod file="${mcp.dir}/recompile.sh" perm="+x"/>
<chmod file="${mcp.dir}/reobfuscate.sh" perm="+x"/>
<chmod file="${forge.dir}/install.sh" perm="+x"/>
<!-- if your building on OSX these 2 should be executable -->
<chmod file="${mcp.dir}/runtime/bin/astyle-osx" perm="+x" />
<chmod file="${mcp.dir}/runtime/bin/jad-osx" perm="+x" />
<!-- Install forge -->
<exec dir="${forge.dir}" executable="cmd" osfamily="windows">
<arg line="/c install.cmd"/>
</exec>
<exec dir="${forge.dir}" executable="sh" osfamily="unix">
<arg value="install.sh" />
</exec>
<!-- Copy BC source -->
<copy todir="${mcpsrc.dir}">
<fileset dir="${src.dir}/common">
<exclude name="**/buildcraft/devel"/>
</fileset>
<filterset>
<filter token="VERSION" value="${bc.version}" />
<filter token="BUILD_NUMBER" value="${build.number}" />
</filterset>
</copy>
</target>
<target name="compile" depends="setup">
<!-- Recompile -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c recompile.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="recompile.sh" />
</exec>
<!-- Reobf -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate.sh" />
</exec>
<!-- Copy BC classes -->
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
<!-- Copy resources -->
<copy todir="${classes.dir}">
<fileset dir="${src.dir}/buildcraft_resources">
<exclude name="build.xml"/>
<exclude name="build.number"/>
</fileset>
<filterset>
<filter token="VERSION" value="${bc.version.full}" />
</filterset>
</copy>
<!-- Copy localizations -->
<copy todir="${classes.dir}">
<fileset dir="${lang.dir}">
<exclude name="README.md"/>
</fileset>
</copy>
</target>
<!-- Zip the compiled files -->
<target name="package" depends="compile">
<jar destfile="${jar.dir}/buildcraft-A-${bc.version.full}.jar" basedir="${classes.dir}"/>
</target>
<!-- Default target to run -->
<target name="main" depends="initialize-version,download-files,clean,package"/>
</project> </project>

View file

@ -3,7 +3,7 @@
"modid": "BuildCraft|Core", "modid": "BuildCraft|Core",
"name": "BuildCraft", "name": "BuildCraft",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more!",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",
@ -20,7 +20,7 @@
"modid": "BuildCraft|Builders", "modid": "BuildCraft|Builders",
"name": "BC Builders", "name": "BC Builders",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Builders Component)",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",
@ -37,7 +37,7 @@
"modid": "BuildCraft|Energy", "modid": "BuildCraft|Energy",
"name": "BC Energy", "name": "BC Energy",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Energy Component)",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",
@ -54,7 +54,7 @@
"modid": "BuildCraft|Factory", "modid": "BuildCraft|Factory",
"name": "BC Factory", "name": "BC Factory",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Factory Component)",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",
@ -71,7 +71,7 @@
"modid": "BuildCraft|Silicon", "modid": "BuildCraft|Silicon",
"name": "BC Silicon", "name": "BC Silicon",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Silicon Component)",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",
@ -88,7 +88,7 @@
"modid": "BuildCraft|Transport", "modid": "BuildCraft|Transport",
"name": "BC Transport", "name": "BC Transport",
"description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)", "description": "Extending Minecraft with pipes, auto-crafting, quarries, engines and much more! (Transport Component)",
"version": "", "version": "@VERSION@",
"credits": "Created by SpaceToad", "credits": "Created by SpaceToad",
"logoFile": "/gfx/buildcraft/logo.png", "logoFile": "/gfx/buildcraft/logo.png",
"mcversion": "", "mcversion": "",