2017-07-07 47 views
0

我與Phing有問題。他只做默認的工作。有沒有人遇到過這種行爲?該環境適用於Windows 10. 感謝您的幫助。Phing確實只是默認的目標

<?xml version="1.0" encoding="UTF-8"?> 
<project name="Test" default="start"> 
    <!-- ============================================ --> 
    <!-- Target: start         --> 
    <!-- ============================================ --> 
    <target name="start"> 
     <echo msg="Start build" /> 
    </target> 
    <!-- ============================================ --> 
    <!-- Target: prepareDirectory      --> 
    <!-- ============================================ --> 
    <target name="prepareDirectory" depends="start"> 
     <echo msg="Making directory build ./build" /> 
     <mkdir dir="./build" /> 
     <echo msg="Making directory install ./install" /> 
     <mkdir dir="./install" />  
    </target>  
    <!-- ============================================ --> 
    <!-- Target: build         --> 
    <!-- ============================================ --> 
    <target name="build" depends="prepareDirectory"> 
     <echo msg="Copying files to build directory..." /> 

     <echo msg="Copying ./about.php to ./build directory..." /> 
     <copy file="./about.php" tofile="./build/about.php" /> 

     <echo msg="Copying ./browsers.php to ./build directory..." /> 
     <copy file="./browsers.php" tofile="./build/browsers.php" /> 

     <echo msg="Copying ./contact.php to ./build directory..." /> 
     <copy file="./contact.php" tofile="./build/contact.php" /> 
    </target> 
</project> 

回答

1

您需要設置其他方式的依賴關係。您的目標「開始」不會觸發您當前代碼的任何其他目標。

試試這個:

<?xml version="1.0" encoding="UTF-8"?> 
<project name="Test" default="build"> 
    <!-- ============================================ --> 
    <!-- Target: start         --> 
    <!-- ============================================ --> 
    <target name="start"> 
     <echo msg="Start build" /> 
    </target> 
    <!-- ============================================ --> 
    <!-- Target: prepareDirectory      --> 
    <!-- ============================================ --> 
    <target name="prepareDirectory" depends="start"> 
     <echo msg="Making directory build ./build" /> 
     <mkdir dir="./build" /> 
     <echo msg="Making directory install ./install" /> 
     <mkdir dir="./install" />  
    </target>  
    <!-- ============================================ --> 
    <!-- Target: build         --> 
    <!-- ============================================ --> 
    <target name="build" depends="prepareDirectory"> 
     <echo msg="Copying files to build directory..." /> 

     <echo msg="Copying ./about.php to ./build directory..." /> 
     <copy file="./about.php" tofile="./build/about.php" /> 

     <echo msg="Copying ./browsers.php to ./build directory..." /> 
     <copy file="./browsers.php" tofile="./build/browsers.php" /> 

     <echo msg="Copying ./contact.php to ./build directory..." /> 
     <copy file="./contact.php" tofile="./build/contact.php" /> 
    </target> 
</project> 

的執行順序將是:開始 - > prepareDirectory - >打造

希望的作品!

+0

它的工作原理。感謝您的幫助。我已經瞭解默認目標的工作原理。 –

+0

您是否可以將答案標記爲已接受,如果這是您正在尋找的內容? – arifCee

+1

我很抱歉。我是「StackOverflow」的新手。我還不知道所有的機制。 –