我在项目中有以下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>
我有一个属性class.path
指向一堆像下面这样的罐子。我想使用此class.path
(由IDE创建)属性作为上述junit
测试类路径的类路径,我尝试过一些事情,那没起效。有人能指出我正确的方向吗?
<condition property="class.path" value="C:/tools/bea/jdk142_19/jre/lib/rt.jar;C:/tools/bea/jdk142_19/jre/lib/jsse.jar;C:/tools/bea/jdk142_19/jre/lib/jce.jar;C:/tools/bea/jdk142_19/lib/tools.jar;${platformhome.local.directory}/server/lib/knex.jar;${platformhome.local.directory}/common/lib/log4j.jar;${platformhome.local.directory}/server/lib/debugging.jar;${platformhome.local.directory}/javelin/lib/javelin.jar;${platformhome.local.directory}/server/lib/wlw-lang.jar;${platformhome.local.directory}/server/lib/weblogic.jar;${platformhome.local.directory}/common/eval/pointbase/lib/pbserver44.jar;${platformhome.local.directory}/common/eval/pointbase/lib/pbclient44.jar;${platformhome.local.directory}/server/lib/webservices.jar;${platformhome.local.directory}/server/lib/webserviceclient.jar;${platformhome.local.directory}/server/lib/webserviceclient+ssl.jar;${platformhome.local.directory}/server/lib/wli.jar;${platformhome.local.directory}/server/lib/xbean.jar;${platformhome.local.directory}/server/lib/wlxbean.jar;${platformhome.local.directory}/server/lib/xqrl.jar;${platformhome.local.directory}/server/lib/netui/netui-compiler.jar;${app.local.directory}/APP-INF/lib/CommonUtilities.jar;${app.local.directory}/APP-INF/lib/junit.jar;${app.local.directory}/APP-INF/lib/log4j.jar">
<or>
<os family="windows"/>
<os name="SunOS"/>
</or>
</condition>
答案 0 :(得分:1)
<pathelement location= ...>
:location
属性指定相对于项目基本目录(或绝对文件名)的单个文件或目录,而path
属性1}}属性接受以冒号或分号分隔的位置列表。
path属性旨在与预定义路径一起使用 - 在任何其他情况下,应首选具有位置属性的多个元素。
..来自HERE
使用<pathelement path="${class.path}" />
应该有效,除非还有其他错误。
答案 1 :(得分:0)
我不明白你是如何实现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>
classpathref
是许多任务的参数,例如javac
,java
和javadoc
我认为 - 在JUnit任务中作为nested element被接受。