[英]How can I specify the classpath in the build file of an ftp tasks
我想直接在我的Ant Build脚本中指定fpt任务的类路径。 我尝试了以下方法:
<target name="ftp-upload" depends="build-html">
<echo message="Ftp upload started with user ${user}" />
<ftp verbose="yes"
remotedir="${ftp.dir}"
server="${server}"
userid="${user}"
password="${password}"
depends="yes">
<fileset dir="${mystuff.dir}/.." />
<classpath refid="build.classpath" />
</ftp>
</target>
和
<target name="ftp-upload" depends="build-html">
<echo message="Ftp upload started with user ${user}" />
<ftp verbose="yes"
remotedir="${ftp.dir}"
server="${server}"
userid="${user}"
password="${password}"
depends="yes"
classpathref="build.classpath"
>
<fileset dir="${mystuff.dir}/.." />
</ftp>
</target>
第一种方法给我以下错误消息:
Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig
第二种方法给我以下错误消息:
ftp doesn't support the "classpathref" attribute
是否可以在构建脚本中为ftp任务设置类路径,还是必须在我的服务器上的构建脚本之外进行? 将构建脚本自包含会很高兴。
解:
只需使用类路径引用重新定义ftp任务:
<taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP">
<classpath>
<pathelement location="\lib\commons-net-1.4.0.jar"/>
</classpath>
</taskdef>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.