ant compiling error for junit testcase in other source folder with similar package structure
<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&开发者_StackOverflow中文版gt;
<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;
^
Your compile.test Ant target uses the compile.test classpath which is declared as:
<path id="classpath.test">
<fileset dir="${basedir}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${build}/src">
<include name="**/*.class"/>
</fileset>
Is the "C:\Project\test\" folder amongst those?
精彩评论