【问题标题】:Include commons-net.jar at the custom location instead of ant install location在自定义位置而不是 ant 安装位置包含 commons-net.jar
【发布时间】:2016-05-17 21:27:32
【问题描述】:

我正在使用来自ant 的ftp 任务。为了让ftp 工作,我需要 commons-net.jar 作为

的依赖项

ANT_HOME/lib 文件夹。

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

ANT_HOME/lib 文件夹?

【问题讨论】:

    标签: ant apache-commons-net


    【解决方案1】:

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

    您可以按如下方式自动安装依赖的 jar:

    <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>
    

    【讨论】:

      猜你喜欢
      • 2015-11-14
      • 2017-06-11
      • 2015-06-05
      • 2013-01-22
      • 1970-01-01
      • 2019-02-05
      • 2018-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多