buildcraft/build.xml

189 lines
5.3 KiB
XML
Raw Normal View History

<project name="BuildCraft" default="main">
<property environment="env"/>
<!-- Properties -->
<property name="build.dir" value="build"/>
<property name="src.dir" value="."/>
<property name="lang.dir" value="../buildcraft.localization"/>
<property name="resources.dir" value="buildcraft_resources"/>
<property name="download.dir" value="download"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="bin"/>
<property name="forge.dir" value="${build.dir}/forge"/>
<property name="mcp.dir" value="${forge.dir}/mcp"/>
<property name="mcpsrc.dir" value="${mcp.dir}/src"/>
<property name="mc.version" value="1.5.1"/>
<property name="forge.version" value="7.7.1.624"/>
<!-- <property name="project.version" value="0.0.0"/>-->
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
<available property="forge-exists" file="${download.dir}/${forge.name}"/>
<available file="${src.dir}/.git" type="dir" property="git.present"/>
<condition property="out-of-date">
<not>
<and>
<available file="${download.dir}/${forge.name}"/>
<available file="${mcpsrc.dir}"/>
</and>
</not>
</condition>
<mkdir dir="${download.dir}"/>
<!-- Targets -->
<!-- Clear build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- Set full version -->
<target name="initialize-version" depends="version-provided,version-not-provided,git.revision">
<property name="project.version.full" value="${project.version}.${build.number}"/>
</target>
<!-- Set unknown build number -->
<target name="version-not-provided" unless="env.BUILD_NUMBER">
<property name="build.number" value="unknown"/>
</target>
<!-- Set build number from environment -->
<target name="version-provided" if="env.BUILD_NUMBER">
<property name="build.number" value="${env.BUILD_NUMBER}"/>
</target>
<target name="git.revision" if="git.present">
<exec executable="git" dir="${src.dir}" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
<condition property="project.version" value="${git.revision}" else="0.0.0">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<!-- Download necessary files -->
<target name="download-files" depends="download-forge"/>
<!-- Download forge (if it doesn't exist) -->
<target name="download-forge" unless="forge-exists">
<get src="http://files.minecraftforge.net/${forge.name}" dest="${download.dir}" usetimestamp="True"/>
</target>
<!-- Setup mcp and forge -->
<target name="setup" depends="download-files" if="out-of-date">
<delete dir="${forge.dir}" failonerror="false"/>
<unzip dest="${forge.dir}/.." src="${download.dir}/${forge.name}"/>
<!-- Fix executable permissions -->
<chmod dir="${forge.dir}" perm="ugo+rx" includes="**.sh"/>
<!-- 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>
</target>
<target name="copy-src">
<!-- Copy sources -->
<copy todir="${mcpsrc.dir}/minecraft">
<fileset dir="${src.dir}/common"/>
<filterset>
<filter token="VERSION" value="${project.version.full}" />
<filter token="BUILD_NUMBER" value="${build.number}" />
</filterset>
</copy>
</target>
<target name="compile" depends="initialize-version,setup,copy-src">
<delete dir="${classes.dir}"/>
<mkdir dir="${classes.dir}"/>
<!-- 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>
<!-- Check for failure -->
<fail message="MCP failed to build">
<condition>
<resourcecontains resource="${mcp.dir}/logs/client_compile.log" substring="error:"/>
</condition>
</fail>
<!-- Reobfuscate -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
2013-04-06 03:36:09 +02:00
<arg line="/c reobfuscate_srg.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
2013-04-06 03:36:09 +02:00
<arg value="reobfuscate_srg.sh"/>
</exec>
<!-- Copy classes -->
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
<!-- Copy resources -->
<copy todir="${classes.dir}">
<fileset dir="${resources.dir}">
<exclude name="build.xml"/>
</fileset>
</copy>
<!-- Copy localizations -->
<copy todir="${classes.dir}" failonerror="false">
<fileset dir="${lang.dir}">
<exclude name="README.md"/>
</fileset>
</copy>
<!-- Reset src dir to post-forge-install state -->
<delete dir="${mcpsrc.dir}/minecraft/buildcraft"/>
</target>
<!-- Package the compiled files -->
<target name="package" depends="compile">
<delete dir="${jar.dir}"/>
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}-${mc.version}-${project.version.full}.jar" basedir="${classes.dir}"/>
<copy todir="${jar.dir}/changelog">
<fileset dir="${resources.dir}/changelog">
<include name="*" />
</fileset>
</copy>
</target>
<!-- Default target to run -->
<target name="main" depends="package"/>
</project>