当我用Ant编译它时,exclude标签不起作用

时间:2015-04-23 03:59:25

标签: eclipse ant

这是Ant build.xml:

    <target name = "build" depends="clean" description = "Compile main source tree java files">
      <mkdir dir = "${build.dir}"/>

      <javac destdir = "${build.dir}" source = "1.6" target = "1.6" debug = "true"
         deprecation = "false" optimize = "false" failonerror = "false" 
        includeantruntime="true" >

        <src path = "${src.dir}"/>
        <include name="com/**/*" />

        <exclude name="${src.dir}/com/cheom/db/DBMethodTest.java"/>
         <classpath refid = "master-classpath"/>

      </javac>
   </target>

这是控制台输出:

    [javac] Compiling 5 source files to /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/classes
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:3: package org.junit does not exist
[javac] import static org.junit.Assert.*;
[javac]                        ^
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:7: package org.junit does not exist
[javac] import org.junit.Test;
[javac]                 ^
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:13: cannot find symbol
[javac] symbol  : class Test
[javac] location: class com.cheom.db.DBMethodTest
[javac]     @Test
[javac]      ^
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:3: package org.junit does not exist
[javac] import static org.junit.Assert.*;
[javac]                        ^
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:7: package org.junit does not exist
[javac] import org.junit.Test;
[javac]                 ^
[javac] /Users/josh/Google Drive/workDocs/JEE/MonitorDBFlow/src/com/cheom/db/DBMethodTest.java:13: cannot find symbol
[javac] symbol  : class Test
[javac] location: class com.cheom.db.DBMethodTest
[javac]     @Test
[javac]      ^
[javac] 3 errors
[javac] Compile failed; see the compiler error output for details.

我想要排除DBMethodTest.java文件但排除标记不起作用。我在Eclipse IDE中尝试过,而Ant版本的终端是1.9.4。我的代码有什么问题吗?

1 个答案:

答案 0 :(得分:0)

您的类路径中没有JUnit jar。

  

-cp path或-classpath path   指定在何处查找用户类文件,以及(可选)注释处理器和源文件。此类路径将覆盖CLASSPATH环境变量中的用户类路径。如果既未指定CLASSPATH,-cp也未指定-classpath,则用户类路径由当前目录组成。有关详细信息,请参阅设置类路径。   javac doc