3
我想直接在我的Ant构建脚本中为fpt任务指定类路径。我试过如下:如何在ftp任务的构建文件中指定类路径
<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任务设置类路径,还是必须在我的服务器上的构建脚本之外执行它?如果让构建脚本自成一体,将会很好。
解决方案:
只是你的classpath参考重新定义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>
感谢您的链接,重新定义fpt任务的窍门: – vogella 2013-02-21 15:58:35