想用Ant直接向ftp傳輸更新后的jar文件,就采用ftp task,按照
http://ant.apache.org/manual/OptionalTasks/ftp.html
的說明:
<target name="ftp update">
<ftp server="xxx.xxx.xxx.xxx" remotedir="/upload/test" userid="anonymous" password="test@test.com">
<fileset dir="${jar-dist}" />
</ftp>
</target>
運行就出錯build failed:
java.lang.NoClassDefFoundError org/apache/commons/net/ftp/FTPClient
根據http://ant.apache.org/manual/install.html#commons-net提示,ftp task需要
jakarta-oro-xxx.jar和commons-net-xxx.jar。下載后放到ant的home目錄下lib中。
本以為這樣就可以了,但是還是出原來的錯。重起Eclipse也沒用。
最后在Preferences->Ant->Runtime->Classpath中Add External Jar,增加這兩個jar后正常。
也就是說,雖然這兩個包放到ant/lib了,但是它默認不加載,可能它默認只加載ant-*.jar。