繁体   English   中英

如何在ftp任务的构建文件中指定类路径

[英]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>

您是否尝试过如何在没有-lib或全局安装的情况下将可选任务加载到ant中的解决方案

我前段时间遇到了类似的问题,我解决了它添加一个新的类加载器。

问候

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM