[英]How can I specify the classpath in the build file of an ftp tasks
I would like to specify the classpath for an fpt task directly in my Ant Build script. 我想直接在我的Ant Build脚本中指定fpt任务的类路径。 I tried the following: 我尝试了以下方法:
<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>
and 和
<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>
The first approach gives me the following error message: 第一种方法给我以下错误消息:
Could not create type ftp due to java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClientConfig
The second approach gives me the following error message: 第二种方法给我以下错误消息:
ftp doesn't support the "classpathref" attribute
Is it possible to set the classpath in the build script for the ftp tasks or do I have to do it outside the build script on my server? 是否可以在构建脚本中为ftp任务设置类路径,还是必须在我的服务器上的构建脚本之外进行? Would be nice to have the build script self-contained. 将构建脚本自包含会很高兴。
Solution: 解:
Just re-define the ftp task with your classpath reference: 只需使用类路径引用重新定义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>
Have you tried the solution commented at How to load an optional task into ant without -lib or global installation? 您是否尝试过如何在没有-lib或全局安装的情况下将可选任务加载到ant中的解决方案? ? ?
I had a similar problem some time ago and I solved it adding a new classloader. 我前段时间遇到了类似的问题,我解决了它添加一个新的类加载器。
Regards 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.