gpt4 book ai didi

java - 来自属性的 Ant-Junit 类路径

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:33 25 4
gpt4 key购买 nike

我的项目中有以下 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指向一堆 jar ,如下所示。我想使用这个 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>

最佳答案

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

..来自HERE

使用 <pathelement path="${class.path}" />应该可以工作,除非有进一步的错误

关于java - 来自属性的 Ant-Junit 类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24870579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com