lundi 11 juillet 2016

cannot find package ant unit tests

I’m trying to execute unit tests using Ant, however I am getting an “error package does not exist” even though I have included the class path of the package.

Folder Structure in Eclipse

build.xml

<property name="src.dir" value="C:/UnitTests/src/com/Project/core/tests/"/>
<property name="build.dir" value="build"/>
<property name="src.jars" value="C:/MyProject/lib"/>
<property name="unit.test.jars" value="C:/UnitTests/lib"/>


<!--Define classpath  -->

<path id="master-classpath">

    <fileset dir="${src.jars}">
        <include name="**/*.jar"/>
    </fileset>

    <fileset dir="${unit.test.jars}">
        <include name="**/*.jar"/>
    </fileset>

</path>

<!--Print out path  -->

<pathconvert pathsep="${line.separator}|   |-- "             
            property="echo.path.compile"             
            refid="master-classpath">
</pathconvert>

<echo>${echo.path.compile}</echo>

<!-- Main Build  -->

<target name="build" description="Compile source tree java files">
    <mkdir dir="${build.dir}"/>

    <javac destdir="${build.dir}" source="1.7" target="1.7" debug="on" includeantruntime="false" >
        <classpath refid="master-classpath"/>
        <src path="${src.dir}"/>
    </javac>
</target>

Error
[javac] Compiling 1 source file to C:/UnitTests/build [javac] C:\MyProject\src\com\project\core\MyApp.java:14: error: package com.project.example does not exist [javac] import com.project.example.AddNumbers;

I need to understand why am i getting this error when i am setting the the class path to .class file correctly? i have tried everything Please help? perhaps this is an Ant issue?

Aucun commentaire:

Enregistrer un commentaire