2012-10-02 50 views
0

所以我有這個目標在我的Ant構建文件:Ant構建文件遷移學說(要求是/否)

<target name="migrate" description="Migrate the database"> 
    <exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true"> 
     <arg line="migrations:migrate"/> 
    </exec> 
</target> 

學說遷移命令問一個問題,並期望是或否的答案,然後再運行雖然。所以我的構建失敗:

[email protected]:~/projects/myproject$ ant migrate 
Buildfile: /home/richard/projects/myproject/build.xml 

migrate: 
    [exec]                
    [exec]      Doctrine Migrations      
    [exec]                
    [exec] 
    [exec] 
    [exec] 
    [exec]      
    [exec] [RuntimeException] 
    [exec] Aborted    
    [exec]      
    [exec] 
    [exec] 
    [exec] migrations:migrate [--write-sql] [--dry-run] [--configuration[="..."]] [--db-configuration[="..."]] [version] 
    [exec] 
    [exec] 
    [exec] WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n) 

BUILD FAILED 
/home/richard/projects/myproject/build.xml:42: exec returned: 1 

Total time: 0 seconds 
[email protected]:~/projects/myproject$ 

我該如何讓ant自動回答yes,以便它能夠運行遷移?

回答

2

這其實很容易:

<target name="migrate" description="Migrate the database"> 
    <exec executable="${basedir}/vendor/bin/doctrine-module" failonerror="true"> 
     <arg line="migrations:migrate --no-interaction"/> 
    </exec> 
</target>