【发布时间】:2013-12-05 18:59:23
【问题描述】:
我使用 Swing 编写了一个小游戏程序,它被组织成包。我一直在努力创建game.app,但几乎没有成功。我正在关注This link,但我什至无法通过第 1 步。
首先我在顶级目录中执行jar cvf HangManProject.jar *。
在此之后,为了创建
build.xml,我右键单击项目文件夹并生成 ant 文件,如下所示。你可以注意到我的HangManProject.jar从上一步坐在那里。在这一步之后,我创建了 build.xml,并在我的顶级目录(与 HangManProject.jar 相同的位置)上可用。
-
现在我按照上面链接的建议尝试了
ant jar来创建 dist/HangManProject.jar。但我收到以下错误消息:构建文件:/Users/Tom/Documents/workspace/HangManProject/build.xml
构建失败 项目“HangManProject”中不存在目标“jar”。
从图中可以看出,HangManProject.jar 存在于同一目录中。我不明白为什么会弹出这个错误。
我也尝试了ant -verbose(实际上并不知道它的作用),我让它成功地工作
build:
BUILD SUCCESSFUL
Total time: 2 seconds
我不知道ant -verbose 是否有帮助,但我想我必须先让ant jar 工作(步骤3),然后才能继续上面链接中的下一步。请给我你的建议。
编辑:
这是我的 build.xml 由 Eclipse 自动生成的
<?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="HangManProject">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../Downloads/eclipse"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
</path>
<path id="HangManProject.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<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="HangManProject.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
</project>
【问题讨论】:
-
你能发布你的 build.xml 吗?看起来它没有“jar”目标
-
@dimoniy:我在上面的编辑中粘贴了 build.xml
标签: java macos bundle executable-jar