[英]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.