简体   繁体   中英

Need to make a ant build file for eclipse project

I have a simple game implemented in eclipse. It consists of about 8 classes. 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".

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.

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.

<?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. You have tasks like <javac> <jar> etc.. To compile your classes and put them in a jar file.

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. You can also adapt that build.xml file to make it work anywhere.

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

I find that ant can be pretty complex easily, it'll take you time to understand it well but it's really doable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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