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

3

我想直接在Ant Build脚本中指定fpt任务的classpath。我尝试了以下内容:

<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任务的类路径是否可行,还是必须在服务器上的构建脚本外部进行?让构建脚本自包含会很好。请注意保留HTML标记。

解决方案:

只需重新定义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>
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接