1

试图将目标属性传递给 FlywayMigration gradle 任务

gradle flywayMigrate -d -Pflyway.target='1.0.0'

或者

gradle flywayMigrate -d -Pflyway.target=1.0.0

或者

flyway {
url = 'jdbc:h2:file:target/foobar'
user = 'sa'
target = '1'}

org.codehaus.groovy.runtime.typehandling.GroovyCastException 失败

09:08:25.855 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '1.0.0' with class 'java.lang.String' to class 'com.googlecode.flyway.core.api.MigrationVersion'

使用的版本和平台:

'com.googlecode.flyway:flyway-gradle-plugin:2.2'

gradle -version
Gradle 1.6
Gradle build time: Tuesday 07 May 2013 9:12:14 AM
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.7.0_05 (Oracle Corporation 23.1-b03)
OS: Mac OS X 10.8.3 x86_64

似乎这会影响尝试设置两个属性时:

  • 目标
  • 初始化版本

仔细观察,这两种方法都覆盖了接受不同类型作为参数的 setter:

Sets the version to tag an existing schema with when executing init.
Parameters:
initVersion The version to tag an existing schema with when executing init. (default: 1)
740 
741     public void setInitVersion(MigrationVersion initVersion) {
742         this.initVersion = initVersion;
743     }


Sets the version to tag an existing schema with when executing init.
Parameters:
initVersion The version to tag an existing schema with when executing init. (default: 1)
749 
750     public void setInitVersion(String initVersion) {
751         this.initVersion = new MigrationVersion(initVersion);
752     }

但是,在 gradle 目标设置中,当在这两种方法上调用 setter 时,这些优先级 groovy 似乎与正确的覆盖类型不匹配:

 /**
 * Sets this property on this Flyway instance if a value has been defined.
 * @param flyway The Flyway instance.
 * @param property The property to set.
 */
private void propSet(Flyway flyway, String property) {
    def value = prop(property);
    if (value != null) {
        flyway[property] = value;
    }
}

问题 574已与 Flyway 一起打开,也许他们可以分享更多关于设置上述属性的正确用法的见解。

4

0 回答 0