2015-04-23 41 views
0

这是蚂蚁的build.xml:当我编译这个使用Ant排除标签不起作用

<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 filem但排除标签不起作用。我在Eclipse IDE中尝试了它,并且使用Ant版本的终端是1.9.4。我的代码有问题吗?

回答

0

你的类路径中没有JUnit jar。

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

+0

谢谢你的回答。但我不知道该怎么做,因为我使用JUnit jar排除所有类。所以当排除使用'JUnit jar'的类时,我是否仍然需要JUnit jar – Joshua