2013-11-28 5 views
0

이상한 오류를 던졌습니다 : 나는 성공적으로 내 서버에 연결할 것을 알고ANT FTP 작업은 1.9.1 여기</p> <p>내 ftp를 macrodef입니다 내가 ANT에서 FTP 작업에 문제가 있었다

<target name="checkAntCommons"> 
      <!-- Test if ant commons-net jar is present --> 
      <echo message="checking for ${ant.library.dir}/commons-net-1.4.1.jar"/> 
      <if> 
      <available file="${ant.library.dir}/commons-net-1.4.1.jar" type="file" /> 
      <then> 
       <echo message="ANT commons-net library is available"/> 
      </then> 
      <else> 
       <echo message="ANT commons-net library is not available" /> 
       <copy file="${ANT_ROOT}/commons-net-1.4.1/commons-net-1.4.1.jar" todir="${ant.library.dir}"/> 
       <fail status="0" message="Must re-run build for changes to take effect" /> 
      </else> 
      </if> 
    </target> 
    <target name="checkJakartaOro"> 
      <!-- Test if ant jakarta-oro jar is present --> 
      <echo message="checking for ${ant.library.dir}/jakarta-oro-2.0.8.jar"/> 
      <if> 
      <available file="${ant.library.dir}/jakarta-oro-2.0.8.jar" type="file" /> 
      <then> 
       <echo message="jakarta-oro library is available"/> 
      </then> 
      <else> 
       <echo message="jakarta-oro library is not available" /> 
       <copy file="${ANT_ROOT}/jakarta-oro-2.0.8/jakarta-oro-2.0.8.jar" todir="${ant.library.dir}"/> 
       <fail status="0" message="Must re-run build for changes to take effect" /> 
      </else> 
      </if> 
    </target> 

<macrodef name="deploySite" description="Deploy site files to ftp"> 
    <sequential> 
     <antcall target="checkAntCommons"/> 
     <antcall target="checkJakartaOro"/> 
     <ftp userid="*******" password="*******" 
      server=***.***.***.***" 
      remotedir="/site/assets/foo" 
      port="21" 
      verbose="true" 
      action="send" 
      passive="yes" 
      systemTypeKey="UNIX" 
      > 
      <fileset dir="./deploy"> 
       <includesfile name="deploy/foo.swf"/> 
      </fileset> 
     </ftp> 
    </sequential> 
</macrodef> 
<target name="deploy" description="deploy foo files"> 
    <deploySite/> 
</target> 

I 때문에 내가 암호를 변경하면 로그인 오류가 생기고, 올바른 암호를 입력하면 문제가 발생합니다. 필자는 항상 filezilla를 통해 연결합니다. 동시 연결의 문제는 아닙니다. 제한이 없기 때문입니다. 나는 다음과 같은 출력을 얻을이 작업을 실행할 때

는 :

$ ant deploy 
Buildfile: f:\var\projects\hof\svn2.-----------------.com\lobby\trunk\build.xml 

deploy: 

checkAntCommons: 
    [echo] checking for F:\bin\ant\lib/commons-net-1.4.1.jar 
    [echo] ANT commons-net library is available 

checkJakartaOro: 
    [echo] checking for F:\bin\ant\lib/jakarta-oro-2.0.8.jar 
    [echo] jakarta-oro library is available 
     [ftp] sending files 

BUILD FAILED 
f:\var\projects\hof\svn2.-----------------------.com\lobby\trunk\build.xml:324: The following error occurred while executing this line: 
f:\var\projects\hof\svn2.-----------------------.com\lobby\trunk\build.xml:309: Syntax error in property: ${ c6W∟5⌂[6▄≈☻wä5↓╚╞K▐Bd≡6?k╥<╞:èbE▒9≡'╗î£Θ┼è├≤╘r≤?öæCu½╞╖§Σ ç▓(σⁿ.?n≡PßΘéK┼ ΣRq!╣T,ò■Ä╠W3║»æ ?√i 
╩↑↓UQa{σ▼î¼≈Lpt■┼Ç☻/α┐┘D`╬!`8&├ òƒ Üj▲?╔ 1Q.ô²¢┴┌Ça£∙▒∙Oækñcl╜vÑl^)w╠G╒╠gäêyPε╘╟7░═µu╚¡I┐N6»º4%▒ƺ≥á=⌂î5←7╚µ 

Total time: 3 seconds 

을 내 macrodef에 전혀 변수가 없습니다. 어떤 이유로 든 ANT가 전송하려고하는 파일의 바이너리 데이터에서 대체물을 구문 분석하려고합니다.

많은 시행 착오 끝에 그 원인을 발견했습니다. 대답은 아래에있다!

답변

0

대답은 파일 세트의 요소가 잘못이다 : 요소가 어떻게 든 따라서 쓰레기를 읽기, 한

<fileset dir="./deploy"> 
    <includesfile name="deploy/foo.swf"/> 
</fileset> 

개미 작업에서 완전히 예측할 수없는 응답 결과.

은 다음과 같이 그것을 :

<fileset> 
    <include name="@{file-name}"/> 
</fileset> 

최종 작업 솔루션은 다음과 같습니다

<macrodef name="deployFile" description="Deploy foo to *******"> 
    <attribute name="file-name" default="none" /> 
    <attribute name="path" default="." /> 
    <attribute name="remote-dir" default="." /> 
    <sequential> 
     <property name="needToResend" value="false"/> 
     <antcall target="checkAntCommons"/> 
     <antcall target="checkJakartaOro"/> 
     <trycatch> 
      <try> 
       <echo message="trying to upload ${basedir}/@{path}/@{file-name} to @{remote-dir}"/> 
       <sendFTPFile file-name="@{file-name}" path="${basedir}/@{path}" remote-dir="@{remote-dir}"/> 
      </try> 
      <catch> 
       <echo message="${basedir}/@{path}/@{file-name} exists in @{remote-dir}"/> 
       <deleteFTPFile file-name="@{file-name}" remote-dir="@{remote-dir}"/> 
       <property name="needToResend" value="true"/> 
      </catch> 
     </trycatch> 
     <if> 
      <equals arg1="${needToResend}" arg2="true"/> 
      <then> 
       <echo message="re-uploading ${basedir}/@{path}/@{file-name} to @{remote-dir}"/> 
       <sendFTPFile file-name="@{file-name}" path="${basedir}/@{path}" todir="@{remote-dir}"/> 
      </then> 
     </if> 
    </sequential> 
</macrodef> 
<macrodef name="sendFTPFile" description="send a file to FTP"> 
    <attribute name="file-name" default="none" /> 
    <attribute name="path" default="." /> 
    <attribute name="remote-dir" default="." /> 
    <sequential> 
     <echo message="sending @{path}/@{file-name} to @{remote-dir}"/> 
     <ftp userid="****" password="********" 
      server="***.***.***.***" 
      remotedir="@{remote-dir}" 
      port="21" 
      verbose="true" 
      action="send" 
      passive="yes" 
      systemTypeKey="UNIX" 
      ignorenoncriticalerrors="true" 
      > 
      <fileset dir="@{path}"> 
       <include name="@{file-name}"/> 
      </fileset> 
     </ftp> 
    </sequential> 
</macrodef> 
<macrodef name="deploySite"> 
    <sequential> 
     <deployFile file-name="foo.bar" path="${DEPLOY_DIR}" remote-dir="/foo/bar/baz"/> 
     <deployFile file-name="*.bar" path="${DEPLOY_DIR}/blah" remote-dir="/foo/bar/baz/blah"/> 
    </sequential> 
</macrodef>