我正在尝试为java jar运行ant构建文件。出于某种原因,每当我尝试运行ant run
时,它都会回来并说,&#34; Element of type target must be terminated by the matching </target> tag
&#34;这看起来很奇怪,因为我看到我确实有一个终止标记用于运行。会不会有其他可能导致这种情况的原因?任何帮助将不胜感激!
<project>
<target name="compile">
<mkdir dir="build/classes"/>
<javac includeantruntime="false" srcdir="." destdir="build/classes"/>
</target>
<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/KnightsTour.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="PlayTour"/>
</manifest>
</jar>
</target>
<target name= "run" depends = "jar">
<java fork='yes' jar="build/jar/KnightsTour.jar"/>
<arg value="${rows}"/>
<arg value="${columns}"/>
<arg value="${attempts}"/>
</java>
</target>
<target name="view">
<exec executable="less">
<arg value="PlayTour.java" />
<arg value="KnightsTour.java" />
</exec>
</target>
<target name= "doc">
<mkdir dir="build/docs"/>
<javadoc sourcefiles="KnightsTour.java, PlayTour.java" destdir="build/docs"/>
</target>
</project>
答案 0 :(得分:0)
<target name= "run" depends = "jar">
<java fork='yes' jar="build/jar/KnightsTour.jar"/>
<arg value="${rows}"/>
<arg value="${columns}"/>
<arg value="${attempts}"/>
</java>
</target>
您正在关闭上面两个块中的Java标记,首先使用/>
内联然后编写</java>
,这会导致您的错误。这就是固定的:
<target name= "run" depends = "jar">
<java fork='yes' jar="build/jar/KnightsTour.jar" >
<arg value="${rows}"/>
<arg value="${columns}"/>
<arg value="${attempts}"/>
</java>
</target>
每当您怀疑XML验证错误时,您应该使用免费的在线XML验证实用程序来至少确认您的文件结构是否正确。这就是我用来快速找到错误的内容:http://www.xmlvalidation.com/index.php?id=1&L=0