繁体   English   中英

需要为Eclipse项目制作一个Ant构建文件

[英]Need to make a ant build file for eclipse project

我有一个在Eclipse中实现的简单游戏。 它包括大约8个班级。 这是我的学校作业。

在上交规范中,写道:“向我发送所有源代码,文档和ant构建文件,这允许编译项目并生成javadoc文档。”

我真的不明白蚂蚁是如何工作的。 我用谷歌搜索了一些教程,但我也听不懂。 我试图在eclipse中生成build.xml文件,但老师说这也不起作用。

有人可以给我一些简单的步骤,还是给我一些真正基础的教程的链接? 感谢帮助。

这是eclipse生成的ant(将项目导出为antbuildfile):这有点奇怪,因为我很久以前删除的BasicPaint类。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
          To include a user specific buildfile here, simply create one in the same
          directory with the processing instruction <?eclipse.ant.import?>
          as the first entry and export the buildfile again. --><project basedir="." default="build" name="Snakes_and_Adders">
<property environment="env"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.8"/>
<property name="source" value="1.8"/>
<path id="Snakes_and_Adders.classpath">
    <pathelement location="bin"/>
</path>
<target name="init">
    <mkdir dir="bin"/>
    <copy includeemptydirs="false" todir="bin">
        <fileset dir="src">
            <exclude name="**/*.java"/>
        </fileset>
    </copy>
</target>
<target name="clean">
    <delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
    <echo message="${ant.project.name}: ${ant.file}"/>
    <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
        <src path="src"/>
        <classpath refid="Snakes_and_Adders.classpath"/>
    </javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target name="BasicPaint">
    <java classname="snakes_and_adders.BasicPaint" failonerror="true" fork="yes">
        <classpath refid="Snakes_and_Adders.classpath"/>
    </java>
</target>
<target name="Game">
    <java classname="snakes_and_adders.Game" failonerror="true" fork="yes">
        <classpath refid="Snakes_and_Adders.classpath"/>
    </java>
</target>
<target name="NewGame">
    <java classname="snakes_and_adders.NewGame" failonerror="true" fork="yes">
        <classpath refid="Snakes_and_Adders.classpath"/>
    </java>
</target>
<target name="PaintingExample">
    <java classname="snakes_and_adders.PaintingExample" failonerror="true" fork="yes">
        <classpath refid="Snakes_and_Adders.classpath"/>
    </java>
</target>

Ant用于执行对构建应用程序有用的任务。 您有诸如<javac> <jar>等任务。要编译您的类并将其放入jar文件中。

我不明白为什么build.xml生成的文件不起作用。。但是您可以以它为例来了解ant的工作原理。 您还可以修改该build.xml文件以使其在任何地方都可以使用。

乍一看,本教程看起来很好地解释了: http : //www.javaworld.com/article/2076208/java-app-dev/automate-your-build-process-using-java-and-ant.html

我发现蚂蚁很容易变得非常复杂,需要花一些时间来很好地理解它,但这确实是可行的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM