Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将flyway.target和flyway.initVersion属性传递给flywayMigrate gradle任务会导致强制转换异常错误_Gradle_Flyway - Fatal编程技术网

将flyway.target和flyway.initVersion属性传递给flywayMigrate gradle任务会导致强制转换异常错误

将flyway.target和flyway.initVersion属性传递给flywayMigrate gradle任务会导致强制转换异常错误,gradle,flyway,Gradle,Flyway,试图将目标属性传递给FlywayMigration gradle任务 gradle flywayMigrate -d -Pflyway.target='1.0.0' 或 或 使用org.codehaus.groovy.runtime.typehandling.GroovyCastException失败 09:08:25.855 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.codehaus.groovy.runtime.t

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

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

使用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目标设置中,groovy在这两种方法上调用setter时,似乎与正确的覆盖类型不匹配:

 /**
 * 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;
    }
}
已经开通了飞行通道
也许他们可以分享一些关于设置上述属性的正确用法的更多见解

你从哪里读到可以像这样设置目标?@PeterNiederwieser描述了将参数作为属性传递的过程,如上所述。。。以及产生相同错误的flyway迁移,不带引号。在文档中,他们不使用任何。相同的结果,有引号或没有引号。我的最后一个想法是尝试使用-D而不是-P。否则,插件作者可能不得不加入。您使用的是哪个Gradle版本和Flyway插件版本?
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     }
 /**
 * 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;
    }
}