具有类似包结构的其他源文件夹中的 junit 测试用例的 ant 编译错误
<target name="compile.src" depends="init" description="compile the source code " >
<javac srcdir="${src}" destdir="${build}/src">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
<compilerarg value="-Xlint"/>
</javac>
</target>
<path id="classpath.test">
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${build}/src">
<include name="**/*.class"/>
</fileset>
</path>
<echo>${src.test} and tausif ${build}\test </echo>
<target name="compile.test" depends="compile.src" description="compile the test code " >
<javac srcdir="${src.test}" destdir="${build}/test" debug="true" classpathref="classpath.test">
<!--classpath refid="classpath.test" /-->
<compilerarg value="-Xlint"/>
</javac>
</target>
我的项目结构是
project
> src
> example.samplePackage
> test
> example.samplePackage
我尝试编译 src 中的第一个源文件夹,然后尝试在类似包结构的测试源文件夹中编译 junit 测试用例期间包含所有类文件。 但它向我显示以下错误。请提出建议。
[javac] C:\Project\test\examples\samplePackage\SampleTest.java:9: cannot find symbol
[javac] symbol : class Sample
[javac] location: package examples.samplePackage
[javac] import example.samplePackage.Sample;
^
<target name="compile.src" depends="init" description="compile the source code " >
<javac srcdir="${src}" destdir="${build}/src">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
<compilerarg value="-Xlint"/>
</javac>
</target>
<path id="classpath.test">
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${build}/src">
<include name="**/*.class"/>
</fileset>
</path>
<echo>${src.test} and tausif ${build}\test </echo>
<target name="compile.test" depends="compile.src" description="compile the test code " >
<javac srcdir="${src.test}" destdir="${build}/test" debug="true" classpathref="classpath.test">
<!--classpath refid="classpath.test" /-->
<compilerarg value="-Xlint"/>
</javac>
</target>
my structure for project is
project
> src
> example.samplePackage
> test
> example.samplePackage
I am trying to compile first source folder in src and then trying to include all class files during compiling junit testcases in test source folder in similar package structure.
But it is showing me below Error.Please suggest something.
[javac] C:\Project\test\examples\samplePackage\SampleTest.java:9: cannot find symbol
[javac] symbol : class Sample
[javac] location: package examples.samplePackage
[javac] import example.samplePackage.Sample;
^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的compile.test Ant目标使用compile.test类路径,其声明为:
“C:\Project\test\”文件夹在其中吗?
Your compile.test Ant target uses the compile.test classpath which is declared as:
Is the "C:\Project\test\" folder amongst those?