在自定义位置包含commons-net.jar而不是ant安装位置

时间:2016-02-08 09:13:25

标签: ant apache-commons-net

我正在使用ftp中的ant任务。要使ftp生效,我需要 commons-net.jar 作为依赖

  

ANT_HOME / lib文件夹。

作为最佳实践,我遵循文件夹结构以将所有外部文件夹保留在自定义的外部Jars文件夹下。有没有办法将 commons-net.jar 保留在自定义文件夹而不是

  

ANT_HOME / lib文件夹?

1 个答案:

答案 0 :(得分:0)

另一个选择是将插件jar放在“$ HOME / .ant / lib”目录中。

您可以按如下方式自动安装相关的罐子:

<project name="demo" default="build">

   <available classname="org.apache.commons.net.ftp.FTP" property="ftp.installed"/>

   <target name="init" unless="ftp.installed">
      <mkdir dir="${user.home}/.ant/lib"/>
      <get dest="${user.home}/.ant/lib/commons-net.jar" src="http://search.maven.org/remotecontent?filepath=commons-net/commons-net/3.3/commons-net-3.3.jar"/>
      <get dest="${user.home}/.ant/lib/oro.jar" src="http://search.maven.org/remotecontent?filepath=oro/oro/2.0.8/oro-2.0.8.jar"/>
      <fail message="FTP task installed. Run ANT again"/>
   </target>

   <target name="build" depends="init">
      <ftp server="ftp.apache.org" userid="anonymous" password="me@myorg.com">
         <fileset dir="htdocs/manual"/>
      </ftp>
   </target>

</project>