简体   繁体   English

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

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

I have a simple game implemented in eclipse. 我有一个在Eclipse中实现的简单游戏。 It consists of about 8 classes. 它包括大约8个班级。 It is for my school assignment. 这是我的学校作业。

In the turn in specification, there is written: "Send me all source codes, documentation and ant build file, which allows the project to be compiled and generate javadoc documentation". 在上交规范中,写道:“向我发送所有源代码,文档和ant构建文件,这允许编译项目并生成javadoc文档。”

I really do not understand how ant works. 我真的不明白蚂蚁是如何工作的。 I googled some tutorials, but I cannot understand them either. 我用谷歌搜索了一些教程,但我也听不懂。 I tried to generate build.xml file in eclipse, but the teacher said that this doesnt work either. 我试图在eclipse中生成build.xml文件,但老师说这也不起作用。

Could someone give me some simple steps or give me link to some really basic tutorial? 有人可以给我一些简单的步骤,还是给我一些真正基础的教程的链接? Thanks for help. 感谢帮助。

This is the eclipse generated ant (export project as antbuildfile): And it is kind of weird, because the class BasicPaint I deleted a long time ago. 这是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 is used to perform tasks that are useful to build applications. Ant用于执行对构建应用程序有用的任务。 You have tasks like <javac> <jar> etc.. To compile your classes and put them in a jar file. 您有诸如<javac> <jar>等任务。要编译您的类并将其放入jar文件中。

I don't see why the build.xml generated file wouldn't work.. But you can take it as an example to understand how ant works. 我不明白为什么build.xml生成的文件不起作用。。但是您可以以它为例来了解ant的工作原理。 You can also adapt that build.xml file to make it work anywhere. 您还可以修改该build.xml文件以使其在任何地方都可以使用。

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

I find that ant can be pretty complex easily, it'll take you time to understand it well but it's really doable. 我发现蚂蚁很容易变得非常复杂,需要花一些时间来很好地理解它,但这确实是可行的。

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

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