<taskdef name="aaa" classname="com.ibm.rpx.ant.AAA" classpathref="rpx.specific.classpath"/>
<target name="aaa_test" description="Runs aaa class to do pseudo translation">
<aaaclasspath="${aaa.path};${aaa.path}\aaa.jar;${ant.path}\ant.jar" config="${config}" target="${basedir}/target" >
<fileset dir="${basedir}/src">
<include name="**/*.properties"/>
</fileset>
</aaa>
</target>
我想为aaa_test 这个target 会去调用com.ibm.rpx.ant.AAA。我想设一个classpath ,现在这里的classpath 设置没有用。
应该怎么设?有谁知道
<target name="aaa_test" description="Runs aaa class to do pseudo translation">
<aaa classpath="${aaa.path};${aaa.path}\aaa.jar;${ant.path}\ant.jar" config="${config}" target="${basedir}/target" >
<fileset dir="${basedir}/src">
<include name="**/*.properties"/>
</fileset>
</aaa>
</target>
我想设置classpath="${aaa.path};${aaa.path}\aaa.jar;${ant.path}\ant.jar",但是像现在这样作为属性设置不行。是否需要在classpathref="rpx.specific.classpath"中设置,有没有人指点一下啊。
为什么不设置个classpath呢?
<path id= "lib.path ">
<fileset dir= "D:/Java/Ant/lib/ ">
<include name= "**/*.jar "/>
</fileset>
</path> <target name= "compile ">
<mkdir dir= "${compile} "/>
<javac srcdir= "${src} " destdir= "${compile} ">
<classpath refid= "lib.path "/>
</javac>
</target>
<taskdef name="rpx" classname="com.ibm.rpx.ant.Rpx" classpathref="rpx.specific.classpath">
<classpath>
<pathelement location="${rpx.path}"/>
<fileset dir="${rpx.path}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef> <target name="rpx_test" description="Runs RPX class to do pseudo translation">
<rpx classpath="${rpx.path};${rpx.path}\rpx.jar;${ant.path}\ant.jar" config="${config}" target="${basedir}/target" >
<fileset dir="${basedir}/src">
<include name="**/*.properties"/>
</fileset>
</rpx>
</target>
我这样配的我把一段classpath的配置放在<taskdef>里面,发现还是没有找到我设置的类
<javac>
<classpath refid="class.path"/>
</javac>
</target>2.设置classpath
<classpath id="class.path">
<fileset dir="lib">
<include name="......"/>
</fileset>
</classpath>
<fileset dir="${basedir}/WebRoot/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${build.classes.dir}"/>
</path><classpath refid="build.classpath"/>
这个测试类用来把当前classpath输出。(一个很简单的功能)package com.test;import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;public class Test extends Task{
public void execute() throws BuildException
{
String [] classPaths = System.getProperty("java.class.path").toString().split(System.getProperty("path.separator"));
System.out.println("output classpath:");
for(String str:classPaths){
System.out.println(str);
}
}
}然后我写下面这段ant脚本来调用这个测试类
<path id="show.specific.classpath">
<pathelement location="c:/Test"/>
</path> <taskdef name="showclasspath" classname="com.test.Test" classpathref="show.specific.classpath" classpath="c:\Test"/> <target name="show" description="show classpath">
<showclasspath>
</showclasspath>
</target>
但是我这样子调用只能输出我在环境变量中定义了的classpath.我想自己在ant script里面设定classpath(不是环境变量中的)然后通过Test类调用来打印出来。当然这只是一个测试类,在实际的开发中我需要这个 classpath的信息去做一些其他的处理我应该怎么在脚本里面设classpath?
ps:
<classpath.../>这种是只能用在<javac> 标签内部的,这里不能用。