Reputation: 6566
I have the following Ant target and path elements in the project.
<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>
I have a property class.path
pointing to a bunch of jars like below. I'd like to use this class.path
(created by IDE) property as the class-path to the above junit
test's classpath, I've tried a few things, it did not work. Could someone point me to the right direction?
<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>
Upvotes: 1
Views: 1700
Reputation: 1493
<pathelement location= ...>
: The location
attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path
attribute accepts colon- or semicolon-separated lists of locations.
The path attribute is intended to be used with predefined paths - in any other case, multiple elements with location attributes should be preferred.
..from HERE
using <pathelement path="${class.path}" />
should work, unless there are further errors.
Upvotes: 1
Reputation: 20163
I don't understand how you've implemented the Ant classpath. Here's mine, which hopefully will help you:
<path id="project_classpath">
<fileset dir="${dir_sandbox_jar_dependencies}" includes="*.jar"/>
<pathelement location="${build.class.dir}"/>
</path>
And then I use it with
<java classname="some.java.class" failonerror="true" classpathref="project_classpath">
<arg value="hello"/>
</java>
classpathref
is a parameter for many tasks, such as javac
, java
, and javadoc
It's also accepted--I think--as a nested element in JUnit task.
Upvotes: 0