开启辅助访问      

站内搜索

搜索
热搜: 下载 1.19 1.20

Minecraft(我的世界)苦力怕论坛

[开发教程] 用Ant进行minecraft编译

发表于 2020-5-7 08:37:22 来自手机 | 显示全部楼层 |阅读模式 IP:河南省
步骤:1.先下载ant。可以到 ant官网 http://ant.apache.org/ 进行下载。
到官网后,先点击Binary Distributions。
                     换页后,把画面拉下来一点
下载.....1.8.4-bin.zip(前面档名省略)。下载好后请先解压缩,放到合适的位置(建议在C槽下建立一个javalib资料夹,裡面可放入这些常用的jar包)。接下来是进行ant的环境配置,配置好后可以在CMD中输入 ant -version查询版本,能够查询到就表示安装成功。
2.在代码资料夹中新建一个build.xml,摆放位置参考下图(参考红色框框,摆放build.xml)
build.xml的内容可以参考官方wiki,网址http://mcp.ocean-labs.de/index.php/Ant_Builds_with_MCP。
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Sample" basedir="." default="all">

   <!-- Your name here -->
   <property name="author" value="C. Reeper" />

   <!-- Your release version here -->
   <property name="version" value="1.0.0" />
<!-- Choose ".zip" or ".jar" as the dist file extension -->
   <property name="filetype" value="zip" />

   <!-- Update if mcp directory isn't in same location as this file -->
   <property name="mcp.dir" location="./mcp" />

   <!-- Update if dist directory isn't in same location as this file -->  
   <property name="dist.dir" location="./dist" />

   <!-- Update only if build directory isn't in same location as this file -->
   <property name="build.dir" location="./build" />

   <!-- Update to point to your Python executable. Example: /usr/bin/python -->
   <!-- The following location is for Windows: -->
   <property name="python" location="${mcp.dir}/runtime/bin/python/python_mcp.exe" />
   <target name="init" description="Initialize build environment">
      <echo message="Cleaning old build and dist, MCP reobf directories" />
      <delete dir="${build.dir}" />
      <delete dir="${dist.dir}" />
      <delete dir="${mcp.dir}/reobf" />

      <echo message="Creating build and dist dirs" />
      <mkdir dir="${build.dir}" />
      <mkdir dir="${dist.dir}" />
   </target>

   <target name="recompile" description="MCP recompile" >
      <exec executable="${python}" dir="${mcp.dir}">
          <arg value="runtime/recompile.py"/>
          <arg value="%*"/>
      </exec>
   </target>

   <target name="reobfuscate" description="MCP reobfuscate">
      <exec executable="${python}" dir="${mcp.dir}">
          <arg value="runtime/reobfuscate.py"/>
          <arg value="%*"/>
      </exec>
   </target>

   <target name="stage" description="Stage resources into build directory">
      <copy todir="${build.dir}">
         <fileset dir="${mcp.dir}/reobf/minecraft" excludes=".svn/**, *.txt" />
      </copy>
      <!-- Copy other stuff specific to your project -->
   </target>

   <target name="all" description="Perform all tasks for a build" depends="init, recompile, reobfuscate, stage, jarzip">
      <echo message="MCP Ant Build Completed!" />
   </target>

   <target name="jarzip" description="Jar (or zip) the project's dist output">
      <mkdir dir="${dist.dir}" />
      <jar destfile="${dist.dir}/${ant.project.name}${version}.${filetype}" duplicate="preserve" index="true" manifestencoding="UTF-8">
         <manifest>
            <attribute name="Built-By" value="MCP (http://mcp.ocean-labs.de)"/>
            <attribute name="Implementation-Vendor" value="${author}"/>
            <attribute name="Implementation-Title" value="${ant.project.name}"/>
            <attribute name="Implementation-Version" value="${version}"/>
         </manifest>
         <fileset dir="${build.dir}" />
      </jar>
   </target>

</project>
记得修改几个地方,
<property name="author" value="C. Reeper" />    作者,自己的作品当然输入自己的名字
<property name="version" value="1.0.0" />          版号
<property name="filetype" value="zip" />              产出是zip或jar
<property name="mcp.dir" location="./mcp" />     主要目录,各位如果从上面看下来,那这地方我的就应该修改成mcp62
都弄好后!!!
把build.xml档案拖拉到你的项目内,会弹出视窗
,选择Link to files就好啦!!
都完成拉,就剩下执行,大功告成!!产出的档案会在dist里面。
苦力怕论坛,感谢有您~
回复

使用道具 举报

发表于 2020-5-20 16:35:37 | 显示全部楼层 IP:北京
我没看懂{:12_325:}{:12_304:}
2# 2020-5-20 16:35:37 回复 收起回复
苦力怕论坛,感谢有您~
回复 支持

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站
关于我们
联系我们
坛史纲要
官方
哔哩哔哩
技术博客
下载
网易版
安卓版
JAVA
反馈
意见建议
教程中心
更多
捐助本站
QQ群
QQ群

QQ群

访问手机版

访问手机版

手机版|小黑屋|系统状态|klpbbs.com

粤公网安备 44200002445329号 | 由 木韩网络 提供云服务 | GMT+8, 2024-3-28 20:42

声明:本站与Mojang以及微软公司没有从属关系

Powered by Discuz! X3.4 粤ICP备2023071842号