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