2017-04-16 88 views
0

這裏是我的代碼xml無法識別我的終止標籤?

<?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>標記。任何想法,我做錯了什麼?

回答

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> 
+0

哦,我的壞,錯誤轉儲讓我困惑,實際的錯誤在那裏撒了謊。我想這是我的不好,因爲沒有使用適當的語法高亮/對齊一些編輯器。謝謝您的幫助 :) – Rawrplus