samliu0219
本帖最后由 samliu0219 于 2012-7-26 10:34 编辑

步骤: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
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <project name="Sample" basedir="." default="all">

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

  5.    <!-- Your release version here -->
  6.    <property name="version" value="1.0.0" />

  7.    <!-- Choose ".zip" or ".jar" as the dist file extension -->
  8.    <property name="filetype" value="zip" />

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

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

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

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

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

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

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

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

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

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

  60. </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里面。

2021.12 数据,可能有更多内容步骤: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

代码:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <project name="Sample" basedir="." default="all">

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

  5.    <!-- Your release version here -->
  6.    <property name="version" value="1.0.0" />

  7.    <!-- Choose ".zip" or ".jar" as the dist file extension -->
  8.    <property name="filetype" value="zip" />

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

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

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

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

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

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

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

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

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

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

  60. </project>

记得修改几个地方,
&lt;property name=&quot;author&quot; value=&quot;C. Reeper&quot; /&gt;    作者,自己的作品当然输入自己的名字
&lt;property name=&quot;version&quot; value=&quot;1.0.0&quot; /&gt;    版号
&lt;property name=&quot;filetype&quot; value=&quot;zip&quot; /&gt;  产出是zip或jar
&lt;property name=&quot;mcp.dir&quot; location=&quot;./mcp&quot; /&gt;  主要目录,各位如果从上面看下来,那这地方我的就应该修改成mcp62
都弄好后!!!
把build.xml档案拖拉到你的项目内,会弹出视窗
,选择Link to files就好啦!!
结果如图

都完成拉,就剩下执行,看下图
。大功告成!!
,产出的档案会在dist里面。

响响丶
看图直接晕了过去

oomanj
表示看不懂

ayaya
ant是个啥东西都没介绍..

第一页 上一页 下一页 最后一页