2012-03-26 46 views
3

出於某種原因,當我使用scp將文件從當前機器移動到使用ant的服務器時,它始終忽略空目錄。Ant build and empty directories

<scp todir="[email protected]:/var/www/html" keyfile="${basedir}\..\keys\prod_default.pem" trust="true"> 
<fileset dir="${staging.dir}" /> 
</scp> 

爲什麼?

完全更新詳細日誌:

D:\BUILD\SCRIPTS>ant -v -f getcom.xml update 
Apache Ant(TM) version 1.8.2 compiled on December 20 2010 
Buildfile: D:\BUILD\SCRIPTS\getcom.xml 
Detected Java version: 1.7 in: C:\Program Files (x86)\Java\jdk1.7.0_02\jre 
Detected OS: Windows Server 2008 R2 
parsing buildfile D:\BUILD\SCRIPTS\getcom.xml with URI = file:/D:/BUILD/SCRIPTS/getcom.xml 
Project base dir set to: D:\BUILD\SCRIPTS 
parsing buildfile jar:file:/C:/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml 
with URI = jar:file:/C:/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file 
[property] Loading D:\BUILD\SCRIPTS\build.properties 
Build sequence for target(s) `update' is [update] 
Complete build sequence is [update, upload, cleanup, staging, export, init, ] 

update: 
    [exec] Current OS is Windows Server 2008 R2 
    [exec] Executing 'C:\\Program Files (x86)\\subversion\\bin\\\svn' with arguments: 
    [exec] 'update' 
    [exec] 'D:\BUILD\SCRIPTS\..\_STAGING\GETOM' 
    [exec] '--username' 
    [exec] 'uuuu' 
    [exec] '--password' 
    [exec] 'uuuu' 
    [exec] 
    [exec] The ' characters around the executable and arguments are 
    [exec] not part of the command. 
    [exec] Updating 'D:\BUILD\_STAGING\GETOM': 
    [exec] At revision 134. 
     [scp] Connecting to xx.0.0.100:22 
     [scp] done. 
     [scp] Connecting to xx.0.2.100:22 
     [scp] done. 

BUILD SUCCESSFUL 
Total time: 8 seconds 

屬性:

svn.repoBaseURL="https://[email protected]" 
svn.username="uuuu" 
svn.password="uuuu" 
svn.bin=C://Program Files (x86)//subversion//bin// 
MSBuildPath=C://WINDOWS//Microsoft.NET//Framework//v4.0.30319//MSBuild.exe 
lib.path.ant-contrib=C:/ant/lib/ant-contrib-1.0b3.jar 

請注意,文件夾名稱已被更改。

+0

你是否在詳細模式下運行它? – 2012-03-26 09:40:56

+0

@AmitBhargava我已更新我的問題以顯示我在詳細模式下獲得的內容。 – Abs 2012-03-26 09:50:36

+0

好吧,它似乎是字面上採取lib.path.ant-contrib而不是替換值。你能不能分享你的構建屬性文件? – 2012-03-26 11:10:57

回答

2

你必須想出一個解決方法。 Ant實現scp的方式意味着空目錄總是被跳過。

它的要點是,SCP類做這樣的:

DirectoryScanner scanner = set.getDirectoryScanner(getProject()); 
Directory root = new Directory(scanner.getBasedir()); 
String[] files = scanner.getIncludedFiles(); 
if (files.length != 0) { 
    ... 
} 

換句話說,如果它至少包含一個文件只處理目錄。

有一個patch for the Scp task code你可能會考慮,但這意味着一個定製的Ant構建。

浮現在腦海中的其他兩個方法都

  • 使目錄非空在一個單獨的步驟
  • 與佔位符文件填充(你可以刪除一旦部署)
  • 創建空目錄
+0

謝謝Martin。我以爲是這樣。我會首先選擇確保所有目錄文件至少有一個文件在其中。 – Abs 2012-04-02 09:42:56