2015-10-16 32 views
1

我使用Gradle 2.7和Gradle Liquibase插件1.1.1。我如何運行我的變更因爲這樣做使用Gradle:我如何在我的正常構建過程中運行我的LIquibase變更集?

gradle build 

我的正常建設的一部分嗎?我現在有這在我的build.gradle文件...

liquibase { 
    activities { 
    main { 
     File propsFile = new File("${project.rootDir}/src/main/resources/liquibase.properties") 
     Properties properties = new Properties() 
     properties.load(new FileInputStream(propsFile)) 
     changeLogFile 'src/main/resources/db.changelog-1.0.xmlll' 
     url '${url}' 
     username '${username}' 
     password '${password}' 
    } 
    runList = main 
    } 
} 

然而,當我運行上面的命令(「gradle這個建」),上面是無法運行。我知道它沒有運行,因爲用戶名/密碼不正確,我沒有以「.xmlll」結尾的更改日誌文件。我還需要添加什麼來確保hte插件總是試圖執行變更集?

回答

3

您需要從構建中定義任務依賴關係以進行更新。

build.dependsOn update 

爲了讓任務可以在測試之前運行(假設你沒有定義一個新的),你可以做

test.dependsOn update 

編號:

+0

如何獲得測試運行之前運行的任務? – Dave

0

你可以在你的gradle構建文件中定義這個

apply plugin: 'liquibase' 
dependencies { 
    classpath 'org.liquibase:liquibase-gradle-plugin:1.2.0' 
} 
liquibase { 
    activities { 
    main { 
    changeLogFile 'changelog.xml' 
    url 'jdbc:h2:db/liquibase_workshop;FILE_LOCK=NO' 
    username 'sa' 
    password '' 
     } 
} 

然後運行這個命令
gradle這個更新

相關問題