BiomesOPlenty/build.xml
2013-11-15 17:30:54 +11:00

288 lines
11 KiB
XML

<project name="Biomes O Plenty" basedir="./" default="build">
<property environment="env" />
<property file="buildspecs.properties" prefix="buildspecs" />
<property name="mod.minecraftversion" value="1" />
<property name="mod.majorversion" value="1" />
<property name="mod.tweakversion" value="3" />
<property name="mod.version" value="${mod.minecraftversion}.${mod.majorversion}.${mod.tweakversion}" />
<condition property="mod.build" value="${env.BUILD_NUMBER}" else="0">
<isset property="env.BUILD_NUMBER" />
</condition>
<property name="mc.version" value="1.6.4" />
<property name="forge.version" value="9.11.1.952" />
<property name="ccc.version" value="0.9.0.7" />
<property name="worldcore.version" value="1.1.0.10" />
<property name="fmp.version" value="1.0.0.182" />
<property name="src.dir" value="" />
<property name="build.dir" value="build" />
<property name="download.dir" value="download" />
<property name="dist.dir" value="dist" />
<property name="forge.dir" value="${build.dir}/forge" />
<property name="fmp.dir" value="${build.dir}/fmp" />
<property name="ccc.dir" value="${build.dir}/ccc" />
<property name="mcp.dir" value="${forge.dir}/mcp" />
<property name="mod.name" value="BiomesOPlenty-universal-${mc.version}-${mod.version}.${mod.build}.jar" />
<property name="dev.name" value="BiomesOPlenty-dev-${mc.version}-${mod.version}.${mod.build}.jar" />
<property name="api.name" value="BiomesOPlenty-api-${mc.version}-${mod.version}.${mod.build}.zip" />
<property name="changelog.name" value="BiomesOPlenty-changelog-${mc.version}-${mod.version}.${mod.build}.txt" />
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip" />
<property name="ccc.name" value="CodeChickenCore-dev%20${ccc.version}.jar" />
<property name="fmp.name" value="ForgeMultipart-dev-${mc.version}-${fmp.version}.jar" />
<!-- Check downloaded dependencies -->
<available property="forge-downloaded" file="${download.dir}/${forge.name}" />
<available property="ccc-downloaded" file="${download.dir}/${ccc.name}" />
<available property="fmp-downloaded" file="${download.dir}/${fmp.name}" />
<!-- Check installed dependencies -->
<property name="build.dependencies.file" value="${build.dir}/dependencies.properties" />
<property prefix="build.dependencies" file="${build.dependencies.file}" />
<condition property="forge-installed">
<equals arg1="${build.dependencies.forge}" arg2="${forge.version}" />
</condition>
<condition property="fmp-installed">
<and>
<isset property="forge-installed" />
<equals arg1="${build.dependencies.fmp}" arg2="${fmp.version}" />
</and>
</condition>
<!-- Make directories -->
<mkdir dir="${build.dir}" />
<mkdir dir="${download.dir}" />
<mkdir dir="${dist.dir}" />
<!-- Targets for downloading dependencies -->
<target name="download-forge" unless="forge-downloaded">
<get src="http://files.minecraftforge.net/${forge.name}" dest="${download.dir}" usetimestamp="true" />
</target>
<target name="download-ccc" unless="ccc-downloaded">
<get src="http://www.chickenbones.craftsaddle.org/Files/New_Versions/${mc.version}/${ccc.name}" dest="${download.dir}" usetimestamp="true" />
</target>
<target name="download-fmp" unless="fmp-downloaded">
<get src="http://files.minecraftforge.net/ForgeMultipart/${fmp.name}" dest="${download.dir}" usetimestamp="true" />
</target>
<!-- Targets for installing dependencies -->
<target name="install-forge" depends="download-forge" unless="forge-installed">
<echo message="Deleting old Forge" />
<delete dir="${forge.dir}" />
<condition property="installargs" value=" --no-assets" else="">
<or>
<isset property="env.BUILD_ID" />
</or>
</condition>
<echo message="Installing Forge with args '${installargs}'." />
<unzip src="${download.dir}/${forge.name}" dest="${forge.dir}/.." />
<property name="fml.python.exe" location="${forge.dir}/fml/python/python_fml.exe" />
<exec dir="${forge.dir}" executable="${fml.python.exe}" osfamily="windows" failonerror="true">
<arg line="install.py${installargs}" />
</exec>
<exec dir="${forge.dir}" executable="python" osfamily="unix" failonerror="true">
<arg line="install.py${installargs}" />
</exec>
<echo message="Updating build.dependencies" />
<delete file="${build.dependencies.file}" />
<propertyfile file="${build.dependencies.file}">
<entry key="forge" value="${forge.version}" />
</propertyfile>
</target>
<target name="install-ccc" depends="install-forge,download-ccc" unless="ccc-installed">
<echo message="Deleting old CodeChickenCore" />
<delete file="${mcp.dir}/lib/${build.dependencies.ccc.name}" />
<echo message="Installing CodeChickenCore" />
<copy file="${download.dir}/${ccc.name}" todir="${mcp.dir}/lib" />
<unzip src="${download.dir}/${ccc.name}" dest="${ccc.dir}">
<patternset>
<include name="**/*.class" />
</patternset>
</unzip>
<echo message="Updating build.dependencies" />
<propertyfile file="${build.dependencies.file}">
<entry key="ccc" value="${ccc.version}" />
<entry key="ccc.name" value="${ccc.name}" />
</propertyfile>
</target>
<target name="install-fmp" depends="install-forge,download-fmp" unless="fmp-installed">
<echo message="Deleting old ForgeMultipart" />
<delete file="${mcp.dir}/lib/${build.dependencies.fmp.name}" />
<delete dir="${fmp.dir}" />
<echo message="Installing ForgeMultipart" />
<copy file="${download.dir}/${fmp.name}" todir="${mcp.dir}/lib" />
<unzip src="${download.dir}/${fmp.name}" dest="${fmp.dir}">
<patternset>
<include name="**/*.class" />
</patternset>
</unzip>
<echo message="Updating build.dependencies" />
<propertyfile file="${build.dependencies.file}">
<entry key="fmp" value="${fmp.version}" />
<entry key="fmp.name" value="${fmp.name}" />
</propertyfile>
</target>
<target name="install-dependencies" depends="install-forge,install-fmp,install-ccc" />
<!-- Targets for building -->
<target name="recompile">
<!-- Copy source -->
<echo message="Copying source" />
<copy todir="${mcp.dir}/src/minecraft">
<fileset dir="common" />
</copy>
<copy todir="${mcp.dir}/src/minecraft">
<fileset dir="apis" />
</copy>
<copy todir="${mcp.dir}/reobf/resources">
<fileset dir="resources" />
</copy>
<!-- Replace Tokens-->
<replace dir="${mcp.dir}/src/minecraft/biomesoplenty" token="@VERSION@" value="${mod.version}" />
<replace dir="${mcp.dir}/src/minecraft/biomesoplenty" token="@BUILD_NUMBER@" value="${mod.build}" />
<replace dir="${mcp.dir}/src/minecraft/biomesoplenty" token="@MC_VERSION@" value="${mc.version}" />
<replace dir="${mcp.dir}/src/minecraft/biomesoplenty" token="1.42.666.42.1" value="9.10.1.871" />
<replace dir="${mcp.dir}/reobf/resources" token="@VERSION@" value="${mod.version}" />
<replace dir="${mcp.dir}/reobf/resources" token="@BUILD_NUMBER@" value="${mod.build}" />
<replace dir="${mcp.dir}/reobf/resources" token="@MC_VERSION@" value="${mc.version}" />
<replace dir="${mcp.dir}/reobf/resources" token="@FORGE_VERSION@" value="${forge.version}" />
<replace dir="${mcp.dir}/reobf/resources" token="@WORLDCORE_VERSION@" value="${worldcore.version}" />
<replace dir="" token="@BUILD_NUMBER@" value="${mod.build}" />
<echo message="Recompiling" />
<property name="mcp.python.exe" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" />
<exec dir="${mcp.dir}" executable="${mcp.python.exe}" osfamily="windows" resultproperty="recompile.code">
<arg line="runtime/recompile.py" />
</exec>
<exec dir="${mcp.dir}" executable="python" osfamily="unix" resultproperty="recompile.code">
<arg line="runtime/recompile.py" />
</exec>
<echo message="Removing source" />
<delete includeemptydirs="true">
<fileset dir="${mcp.dir}/src/minecraft">
<present present="both" targetdir="common" />
<present present="both" targetdir="apis" />
</fileset>
</delete>
<fail message="Failed to recompile">
<condition>
<isfailure code="${recompile.code}" />
</condition>
</fail>
</target>
<target name="reobfuscate">
<echo message="Copying ForgeMultipart" />
<copy todir="${mcp.dir}/bin/minecraft">
<fileset dir="${fmp.dir}" />
</copy>
<echo message="Copying CodeChickenCore" />
<copy todir="${mcp.dir}/bin/minecraft">
<fileset dir="${ccc.dir}" />
</copy>
<echo message="Reobfuscating" />
<property name="mcp.python.exe" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" />
<exec dir="${mcp.dir}" executable="${mcp.python.exe}" osfamily="windows" resultproperty="reobfuscate.code">
<arg line="runtime/reobfuscate.py --srgnames" />
</exec>
<exec dir="${mcp.dir}" executable="python" osfamily="unix" resultproperty="reobfuscate.code">
<arg line="runtime/reobfuscate.py --srgnames" />
</exec>
<echo message="Removing ForgeMultipart" />
<delete includeemptydirs="true">
<fileset dir="${mcp.dir}/bin/minecraft">
<present present="both" targetdir="${fmp.dir}" />
</fileset>
<fileset dir="${mcp.dir}/reobf/minecraft">
<present present="both" targetdir="${fmp.dir}" />
</fileset>
</delete>
<echo message="Removing CodeChickenCore" />
<delete includeemptydirs="true">
<fileset dir="${mcp.dir}/bin/minecraft">
<present present="both" targetdir="${ccc.dir}" />
</fileset>
<fileset dir="${mcp.dir}/reobf/minecraft">
<present present="both" targetdir="${ccc.dir}" />
</fileset>
</delete>
<echo message="Copying DepLoader.class from CCC" />
<copy todir="${mcp.dir}/reobf/minecraft/codechicken/core/launch/">
<fileset dir="${ccc.dir}/codechicken/core/launch/" includes="DepLoader*.class" />
</copy>
<fail message="Failed to reobfuscate">
<condition>
<isfailure code="${reobfuscate.code}" />
</condition>
</fail>
</target>
<target name="package">
<echo message="Building Jar" />
<mkdir dir="${dist.dir}" />
<echo message="Packaging BiomesOPlenty Universal" />
<jar destfile="${dist.dir}/${mod.name}" manifest="${mcp.dir}/reobf/resources/MANIFEST.MF">
<fileset dir="${mcp.dir}/reobf/minecraft" includes="**/biomesoplenty/**, codechicken/core/launch/DepLoader**" />
<fileset dir="${mcp.dir}/reobf/resources" excludes="MANIFEST.MF">
</fileset>
</jar>
<copy todir="tmp/src">
<fileset dir="${mcp.dir}/src/minecraft" includes="**/biomesoplenty/**"/>
</copy>
<echo message="Packaging BiomesOPlenty Dev" />
<jar destfile="${dist.dir}/${dev.name}" manifest="${mcp.dir}/reobf/resources/MANIFEST.MF">
<fileset dir="tmp" includes="**/src/**" />
<fileset dir="${mcp.dir}/bin/minecraft" includes="**/biomesoplenty/**, codechicken/core/launch/DepLoader**" />
<fileset dir="${mcp.dir}/reobf/resources" excludes="MANIFEST.MF">
</fileset>
</jar>
<echo message="Packaging BiomesOPlenty Api" />
<zip destfile="${dist.dir}/${api.name}">
<fileset dir="${mcp.dir}/src/minecraft" includes="**/biomesoplenty/api/**" />
</zip>
<echo message="Renaming BiomesOPlenty Changelog" />
<move file="changelog.txt" tofile="${dist.dir}/${changelog.name}"/>
</target>
<target name="build">
<antcall target="install-dependencies" />
<antcall target="recompile" />
<antcall target="reobfuscate" />
<antcall target="package" />
</target>
</project>