簡體   English   中英

如何在ftp任務的構建文件中指定類路徑

[英]How can I specify the classpath in the build file of an ftp tasks

我想直接在我的Ant Build腳本中指定fpt任務的類路徑。 我嘗試了以下方法:

<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任務設置類路徑,還是必須在我的服務器上的構建腳本之外進行? 將構建腳本自包含會很高興。

解:

只需使用類路徑引用重新定義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>

您是否嘗試過如何在沒有-lib或全局安裝的情況下將可選任務加載到ant中的解決方案

我前段時間遇到了類似的問題,我解決了它添加一個新的類加載器。

問候

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM