Java 来自属性的Ant Junit类路径

Java 来自属性的Ant Junit类路径,java,ant,junit,Java,Ant,Junit,我在项目中有以下Ant目标和路径元素 <project> ..... <path id="MyProject.classpath" location="${class.path}"> <pathelement location="${output.directory}/ant-junit.jar" /> <pathelement location="${output.directory}/junit.jar" /> <

我在项目中有以下Ant目标和路径元素

<project>
.....
<path id="MyProject.classpath" location="${class.path}">
    <pathelement location="${output.directory}/ant-junit.jar" />
    <pathelement location="${output.directory}/junit.jar" />
    <fileset dir="${output.directory}">
        <include name="**/*.jar" />
    </fileset>
    <pathelement location="${class.path}"/> <!-- This did not work -->
    <dirset dir="${dest.path}">         
    </dirset>
</path>

<path id="classpath.test">
    <fileset dir="${output.directory}">
        <include name="**/*.jar" />
    </fileset>
</path>

<target name="test">      
    <echo>In Test</echo>  
    <mkdir dir="${junit.output.dir}" />
    <junit>
        <classpath refid="MyProject.classpath">
        </classpath>           
        <batchtest todir="${junit.output.dir}">
            <formatter type="plain" usefile="false"/>
            <formatter type="plain" />
            <fileset dir="${src.path}">
                <include name="**/*Test*.java" />
            </fileset>
        </batchtest>    
    </junit>
</target>
....
</project>

我不明白您是如何实现Ant类路径的。这是我的,希望能帮助你:

<path id="project_classpath">
   <fileset dir="${dir_sandbox_jar_dependencies}" includes="*.jar"/>
   <pathelement location="${build.class.dir}"/>
</path>

然后我把它和

<java classname="some.java.class" failonerror="true" classpathref="project_classpath">
   <arg value="hello"/>
</java>

,及

我认为,它也被接受为JUnit中的一项任务。

:属性
location
指定一个单个文件或相对于项目基本目录(或绝对文件名)的目录,而
path
属性接受以冒号或分号分隔的位置列表
路径属性用于预定义的路径-在任何其他情况下,应首选具有位置属性的多个元素

…来自


除非有进一步的错误,否则使用
应该可以工作。

您好,请记住,ant类路径在build.xml文件中。我需要设置junit任务的类路径。但是路径在一个属性类中。路径。是的。我不能肯定。我希望分享我使用的东西会有所帮助。
<java classname="some.java.class" failonerror="true" classpathref="project_classpath">
   <arg value="hello"/>
</java>