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.
* Linux users will need the latest version of astyle installed as well.
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. Navigate to basedir/src in a shell and run `ant clean package` (this will take 2-5 minutes)
1. The compiled and obfuscated jars will be in basedir/build/dist
1. Navigate to basedir/Buildcraft in a shell and run `ant` (this will take 2-5 minutes)
1. The compiled and obfuscated jar will be in basedir/build/dist
Your directory structure should look like this:
***
@ -26,10 +27,12 @@ Your directory structure should look like this:
\- bin
|- minecraft.jar
|- ...
\- src
|- buildcraft_client
|- buildcraft_server
\- BuildCraft
|- buildcraft_resources
|- common
|- ...
\- BuildCraft-Localization
|- lang
***

279
build.xml
View file

@ -1,136 +1,215 @@
<project name="Buildcraft" basedir="../" default="main">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<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 environment="env" />
<!-- Properties -->
<property name="build.dir" value="build"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="src.dir" value="BuildCraft"/>
<property name="lang.dir" value="BuildCraft-Localization"/>
<property name="download.dir" value="download"/>
<property name="files.minecraft.dir" value="jars"/>
<property name="download.dir" value="download"/>
<property name="files.minecraft.dir" value="jars"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/dist"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/dist"/>
<property name="mcp.dir" value="${build.dir}/mcp"/>
<property name="forge.dir" value="${mcp.dir}/forge"/>
<property name="mcp.dir" value="${build.dir}/mcp"/>
<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="forge.version" value="4.0.0.232"/>
<property name="bc.version" value="3.1.8"/>
<property name="bc.version.full" value="${bc.version}.${env.BUILD_NUMBER}"/>
<property name="mcp.version" value="72"/>
<property name="forge.version" value="4.0.0.232"/>
<property name="bc.version" value="3.1.8"/>
<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"/>
<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="clean">
<delete dir="${build.dir}"/>
</target>
<unzip dest="${mcp.dir}">
<fileset dir="${download.dir}">
<include name="mcp*.zip"/>
</fileset>
</unzip>
<!-- Set build number -->
<target name="initialize-version" depends="version-provided,version-not-provided">
<property name="bc.version.full" value="${bc.version}.${build.number}"/>
<echo message="Starting build for ${bc.version.full}"/>
</target>
<unzip dest="${mcp.dir}">
<fileset dir="${download.dir}">
<include name="minecraftforge-src-*.zip"/>
</fileset>
</unzip>
<target name="version-not-provided" unless="env.BUILD_NUMBER">
<buildnumber/>
</target>
<copy todir="${mcp.dir}/jars">
<fileset dir="${files.minecraft.dir}"/>
</copy>
<target name="version-provided" if="env.BUILD_NUMBER">
<property name="build.number" value="${env.BUILD_NUMBER}"/>
</target>
<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"/>
<!-- Download necessary files -->
<target name="download-files" depends="download-mcp,download-forge"/>
<!-- 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" />
<!-- Download ant-contrib, necessary to be able to download forge (only if neither forge zip nor ant-contrib exist) -->
<target name="download-ant-contrib" unless="should-download-ant-contrib">
<!-- Install forge -->
<exec dir="${forge.dir}" executable="cmd" osfamily="windows">
<arg line="/c install.cmd"/>
</exec>
<echo message="Getting: ant-contrib"/>
<mkdir dir="${download.dir}/tmp"/>
<exec dir="${forge.dir}" executable="sh" osfamily="unix">
<arg value="install.sh" />
</exec>
<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"/>
<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"/>
<!-- Copy BC source -->
<copy todir="${clientsrc.dir}">
<fileset dir="${src.dir}/common">
<exclude name="**/buildcraft/devel"/>
</fileset>
<filterset>
<filter token="VERSION" value="${bc.version}" />
</filterset>
</copy>
<unzip src="${download.dir}/tmp/ant-contrib-1.0b3-bin.zip" dest="${download.dir}"/>
<unzip src="${download.dir}/tmp/commons-codec-1.6-bin.zip" dest="${download.dir}/tmp"/>
</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 -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c recompile.bat"/>
</exec>
</target>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="recompile.sh" />
</exec>
<!-- Download mcp -->
<target name="download-mcp">
<!-- Reobf -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate.bat"/>
</exec>
<get src="http://mcp.ocean-labs.de/files/mcp${mcp.version}.zip" dest="${download.dir}" usetimestamp="True"/>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate.sh" />
</exec>
</target>
<!-- Copy BC classes -->
<copy todir="${classes.dir}/client">
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
<!-- Download forge (if it doesn't exist) -->
<target name="download-forge" depends="download-ant-contrib" unless="forge-exists" >
<!-- Copy resoucres -->
<copy todir="${classes.dir}/client">
<fileset dir="${src.dir}/buildcraft_resources"/>
</copy>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
<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>

View file

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