简体   繁体   English

导入Ant构建文件时,Eclipse无法将测试文件夹识别为源文件夹

[英]Eclipse don't recognize test folder as source folder when importing ant build file

I have an ant build file for a java project the project tree looks like this : 我有一个Java项目的ant构建文件,项目树如下所示:
DataBaseFidling. 数据库修复。
|-->src (contains production code source) |-> src(包含生产代码源)
|-->tests (contains tests code source) |->测试(包含测试代码源)
|-->bin (contains .class) |-> bin(包含.class)
|-->reports(contains junit xml reports) |->报告(包含junit xml报告)
|-->build.xml |-> build.xml

Whenever I import this project with eclipse using "Java Project From Existing Ant Build File", eclipse does not reconize the tests folder as a source folder. 每当我使用“来自现有Ant构建文件的Java项目”将带有eclipse的项目导入时,eclipse都不会将tests文件夹重新协调为源文件夹。
What to do to fix this? 如何解决此问题?
Here is the ant build file : 这是ant构建文件:
The DatabaseFidling Project. DatabaseFidling项目。

     <property name="src.dir" location="./src/" />     
     <property name="tests.dir" location="./tests/" />     
     <property name="bin.dir" location="./bin/" />     
     <property name="lib.dir" location="/home/chedy/workspace/lib"/>

     <target name="clean">
         <delete verbose="true">
             <fileset dir="${bin.dir}"/>
         </delete>
     </target>

     <target name="compile">
        <javac srcdir="${src.dir}" destdir="${bin.dir}">
        </javac>
        <javac srcdir="${tests.dir}" destdir="${bin.dir}">
             <classpath>
                <pathelement location="${lib.dir}/junit4.jar"/>
                <pathelement location="${lib.dir}/mockito-all-1.9.5.jar"/> 
                <pathelement location="${lib.dir}/SQLScriptRunner.jar"/> 
            </classpath>
        </javac>
     </target>

     <target name="test" depends="compile">
        <junit printsummary="yes" fork="true" >
            <formatter type="xml"/> 
            <classpath>
                <pathelement path="${bin.dir}"/> 
                <pathelement location="${lib.dir}/junit4.jar"/>
                <pathelement location="${lib.dir}/mockito-all-1.9.5.jar"/> 
                <pathelement location="${lib.dir}/SQLScriptRunner.jar"/>
                <pathelement location="${lib.dir}/mysql-connector-java-5.1.23-bin.jar" />
            </classpath>
            <batchtest todir="./report">
                 <fileset dir="${bin.dir}">
                         <include name="**/**Test*.*"/> 
                 </fileset>  
            </batchtest>
        </junit>
     </target>

     <target name="run" depends="compile">
        <java classname="com.esprit.is.Main" fork="true">
            <classpath>
                 <pathelement path="${bin.dir}"/>
                 <pathelement location="${lib.dir}/mysql-connector-java-5.1.23-bin.jar" />
            </classpath>
        </java>
     </target>

</project>

编译目标必须包含一个javac任务,该任务同时编译src和test文件夹。

You can manually add the test folder as a source folder. 您可以手动将测试文件夹添加为源文件夹。 Right click the project, Build Path -> Configure Build Path -> Java Build Path. 右键单击项目,构建路径->配置构建路径-> Java构建路径。 In the Source tab, click Link Source then browse to your folder. 在“源”选项卡中,单击“链接源”,然后浏览到您的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM