这是我的代码
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant" default="main" basedir=".">
<!-- Vytvorime si cesty-->
<property name="src.dir" location="ija/ija2016/homework2"/>
<oroperty name="build.dir" location="bin"/>
<property name="test.output.dir" location="output"/>
<path id="junit.class.path"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="${build.dir}"/>
</path>
<!-- Funkcia pre vytvorenie adresarov -->
<target name="makedir">
<mkdir dir="${build.dir}" />
<mkdir dir="${test.output.dir}" />
</target>
<!-- Funkcia pre vymazanie adresarov -->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${test.output.dir}" />
</target>
<!-- Compile funkcia pre 3. ulohu -->
<target name="compile">
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath refid="junit.class.path"/>
</javac>
<!-- Run funkcia pre 3. ulohu -->
<target name="run" depends="compile">
<junit printsummary="on" fork="true" haltonfailure="yes">
<classpath refid="junit.class.path" />
<formatter type="xml" />
<batchtest todir="${test.output.dir}">
<fileset dir="${src.dir}">
<include name="**/*HomeWork2Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="main" depends="compile, junit">
<description>Ant pre spustenie testov HomeWork2Test</description>
</target>
</project>
这是我的错误代码:
建筑失败
/(文件路径)/build.xml:12:元素类型“project” 必须由匹配的结束标记"</project>"
终止。
尽管我的代码清楚地说明了终止</project>
标记。知道我做错了什么吗?
答案 0 :(得分:1)
您的路径XML
<path id="junit.class.path"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="${build.dir}"/>
</path>
在结束path
标记的第一行包含斜杠。
将第一行更改为
<path id="junit.class.path">
后还需要
</target>
结束标记
<target name="compile">
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath refid="junit.class.path"/>
</javac>
<!-- Run funkcia pre 3. ulohu -->
<target name="run" depends="compile">
<junit printsummary="on" fork="true" haltonfailure="yes">
<classpath refid="junit.class.path" />
<formatter type="xml" />
<batchtest todir="${test.output.dir}">
<fileset dir="${src.dir}">
<include name="**/*HomeWork2Test*.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="main" depends="compile, junit">
<description>Ant pre spustenie testov HomeWork2Test</description>
</target>