2012-05-17 38 views
4

我想设置Ant来运行我的测试,但是我的测试无法编译。 错误在于它无法找到正在测试的类,即使我将它们放在类路径中。我什至输出类路径,他们在上面。Ant:把类放在类路径上,但它们不被看到

蚂蚁:

<target name="compile"> 
    <echo>compiling code</echo> 
    <javac debug="true" srcdir="${src}" destdir="${build}" classpathref="build.path" /> 

    <echo>compiling tests</echo> 

    <echo message="${toString:build.test.path}" /> 

    <javac debug="true" srcdir="${test}" destdir="${build.test}" classpathref="build.test.path" /> 
</target> 
<path id="build.test.path">   
    <fileset dir="${build}"> 
     <include name="**/*.class"/> 
    </fileset> 
    <fileset dir="${install}"> 
     <include name="junit-4.11.jar"/> 
    </fileset> 
</path> 

这是控制台输出:

compile: 
[echo] compiling code 
[javac] C:\PetProjects\timesheet\build.xml:37: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 
[javac] Compiling 2 source files to C:\PetProjects\timesheet\build 
[echo] 
[echo] 
[echo] compiling tests 
[echo] 
[echo] 
[echo] C:\PetProjects\timesheet\build\com\me\timesheet\exceptions\BadBlockException.class;C:\PetProjects\timesheet\build\com\me\timesheet\pojo\Block.class;C:\Installations\junit-4.11.jar 
[echo] 
[echo] 
[javac] C:\PetProjects\timesheet\build.xml:47: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 
[javac] Compiling 1 source file to C:\PetProjects\timesheet\build-test 
[javac] C:\PetProjects\timesheet\test\com\me\timesheet\pojo\BlockTest.java:9: cannot find symbol 
[javac] symbol : class Block 
[javac] location: package com.me.timesheet.pojo 
[javac] import com.me.timesheet.pojo.Block; 
[javac]        ^
[javac] C:\PetProjects\timesheet\test\com\me\timesheet\pojo\BlockTest.java:11: package com.me.timesheet.exceptions does not exist 
[javac] import com.me.timesheet.exceptions.BadBlockException; 

回答

2

你需要把该目录C:\PetProjects\timesheet\build在classpath,而不是个人类。所以当代码参考com.me.timesheet.pojo.Block时,该类在路径C:\PetProjects\timesheet\build\com\me\timesheet\pojo\Block.class

相关问题