开发者

ant compiling error for junit testcase in other source folder with similar package structure

开发者 https://www.devze.com 2023-04-06 05:57 出处:网络
<target name=\"compile.src\" depends=\"init\" description=\"compile the source code \" > <javac srcdir=\"${src}\" destdir=\"${build}/src\">
    <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?

0

精彩评论

暂无评论...
验证码 换一张
取 消