2016-10-18 6 views
0

私はANTFILE_Bの内側にターゲットを呼び出すいくつかの目標を持って、私はANTFILE_Aを作成している主なサブディレクトリには、私のファイルディレクトリAntビルドディレクトリを適切

build/ 
    mainfolder/ 
    ANTFILE_A 
    subfolder1/ 
     ANTFILE_B 
     subfolder2/ 
      ANTFILE_C 

に次のような構造を持っています。ほとんどの場合、ターゲットがすべて機能しますが、1つのケースを除いて、私は理由を理解できないようです。私はsubfolder2のような他のsubdirectoresの一部をクリーンアップクリーンターゲットとantfileを持つサブフォルダ1ディレクトリ内

<target name="clean-subfoler1" description="Cleans subdirectories"> 
    <ant dir="${subfolder1-dir}" antfile="antfile_b.xml" target="clean"/> 
</target> 

:ANTFILE_Aで

は、私は、次があります。私がsubfolder1ディレクトリ内のアリクリーンターゲットを呼び出すと、すべて正常に動作し、問題はありません。

上記のターゲットコマンドをメインフォルダのANTFILE_Aから呼び出してみると、問題が発生します。

私はこのようになって、問題保つ

:起こっていただきました!私はantfile_aからのcleanコマンドを呼び出すときに何らかの理由でそれがsubfolder1ディレクトリをスキップし、内からsubfolder2を探しているように見えるということですので

Invalid file: D:\build\mainfolder\subfolder2\antfile_c.xml 

メインディレクトリ。問題は、サブフォルダ2がサブフォルダ1の下にネストされていることです。

今、basedirが正しく設定されているかどうかをテストしました。実際には、その特定のターゲットのD:\build\mainfolder\subfolder1に正しく一致しています。

これは私がサブディレクトリのフォルダに

を設定する方法である私は、サブantfiles内の任意のプロパティを変更することなく動作するように、このターゲットを取得できるようにしたいと思います。私はinheritAllを見てみましたが、それのどれも私のために働いていませんでした。

答えて

1

私はあなたの質問を取得する場合、私はあなたがantfile_c.xml

としてアリファイル1あなたのターゲットを呼び出す前に、多分あなたの蟻があなたのファイルを削除していることを信じている:antfile 2

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <project name="Demo" default="clean-subfoler1" basedir="."> 

    <property name="subfolder1-dir" value="**path to subfolder1**"/> 

    <target name="clean-subfoler1" description="Cleans subdirectories"> 
     <ant dir="${subfolder1-dir}" antfile="antfileB.xml" target="clean"/> 
    </target> 
    </project> 

を:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    <project name="Demo" default="clean" basedir="."> 

    <property name="subfolder2-dir" value="**path to subfolder2**"/> 

    <target name="clean" description="Cleans subdirectories"> 
     <echo message="in antfileB"/> 
      <echo message="delete files in subFolder2"/> 
      <delete file="antfileC.xml"/> 
      <echo message="delete directory subFolder2"/> 
      <delete dir="${subfolder2-dir}"/> 
    </target> 

    </project> 

私はantを実行:

clean-subfoler1: 

clean: 
    [echo] in antfileB 
    [echo] delete files in subFolder2 
    [delete] Deleting: **path to** /mainfolder/subfolder1/subfolder2/antfileC.xml 
    [echo] delete directory subFolder2 
    [delete] Deleting directory **path to**/mainfolder/subfolder1/subfolder2 

BUILD SUCCESSFUL 
Total time: 0 seconds 

あなたのエラーを解決するには、まずファイルを削除する必要があります。

clean-subfoler1: 

clean: 
    [echo] in antfileB 
    [echo] delete files in subFolder2 
    [delete] Deleting: **path to**/mainfolder/subfolder1/subfolder2/antfileC.xml 
    [echo] call the file 

BUILD FAILED 
**path to**/mainfolder/antfileA.xml:7: The following error occurred while executing this line: 
**path to**/mainfolder/subfolder1/antfileB.xml:11: The following error occurred while executing this line: 
java.io.FileNotFoundException: **path to**/mainfolder/subfolder1/subfolder2/antfileC.xml (No such file or directory)