Liquibase groovy dsl说无法识别的根元素changeSet

时间:2018-09-27 17:42:15

标签: gradle groovy liquibase

我正在尝试学习Liquibase,并使用Liquibase,Liquibase Groovy DSL和Liquibase Gradle插件建立了一个简单的Gradle项目。

当我运行诸如updateupdateSql之类的任务时,会引发Unrecognized root element changeSet错误。我在做什么错了?

src/main/db/changeset.groovy中的变更集文件包含:

databaseChangeLog {
   changeSet(id: '1.0-test-changeset', author='aoife') {
       createTable(tableName: 'foo', remarks: 'Foo table for testing liquibase') {
           column(name: 'bar', type: 'varchar(60)', remarks: 'lots of bars')
           column(name: 'baz', type: 'varchar(15)', remarks: 'even more bazes')
       }
   }
}

build.gradle包含:

plugins {
    id 'groovy'
    id 'application'
    id 'org.liquibase.gradle' version '2.0.1'
}

version = "1.0"
group = "liquitest"
mainClassName = "liquitest.LiquiTest"

repositories {
    maven {
        url "${nexusUrl}/maven-public"
    }
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.5.2'
    compile 'com.oracle.jdbc:ojdbc8:12.2.0.1'
    compile 'ch.qos.logback:logback-classic:1.2.3'

    testCompile 'org.spockframework:spock-core:1.2-RC3-groovy-2.5'

    liquibaseRuntime 'org.liquibase:liquibase-core:3.6.1'
    liquibaseRuntime 'org.liquibase:liquibase-groovy-dsl:2.0.1'
    liquibaseRuntime 'com.oracle.jdbc:ojdbc8:12.2.0.1'
}

liquibase {
    activities {
        main {
            changeLogFile 'src/main/db/changeset.groovy'
            url project.ext.oracleInstance
            username project.ext.oracleUser
            password project.ext.oraclePassword
        }
    }
}

./gradlew updateSql的输出:

> Task :updateSQL FAILED
liquibase-plugin: Running the 'main' activity...
Starting Liquibase at Thu, 27 Sep 2018 10:38:37 PDT (version 3.6.1 built at 2018-04-11 09:05:04)
Unexpected error running Liquibase: Unrecognized root element changeSet
liquibase.exception.ChangeLogParseException: Unrecognized root element changeSet
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
        at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:247)
        at liquibase.parser.ext.GroovyLiquibaseChangeLogParser$_getChangeLogMethodMissing_closure3.doCall(GroovyLiquibaseChangeLogParser.groovy:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:84)
        at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:939)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1262)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
        at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
        at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
        at groovy.lang.Script.invokeMethod(Script.java:80)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:369)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
        at Script1$_run_closure1.doCall(Script1.groovy:2)
        at Script1$_run_closure1.doCall(Script1.groovy)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
        at liquibase.parser.ext.GroovyLiquibaseChangeLogParser.processDatabaseChangeLogRootElement(GroovyLiquibaseChangeLogParser.groovy:136)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
        at liquibase.parser.ext.GroovyLiquibaseChangeLogParser$_getChangeLogMethodMissing_closure3.doCall(GroovyLiquibaseChangeLogParser.groovy:93)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:84)
        at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:939)
        at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1262)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
        at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1125)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
        at Script1.run(Script1.groovy:1)
        at Script1$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
        at liquibase.parser.ext.GroovyLiquibaseChangeLogParser.parse(GroovyLiquibaseChangeLogParser.groovy:64)
        at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217)
        at liquibase.Liquibase.update(Liquibase.java:190)
        at liquibase.Liquibase.update(Liquibase.java:274)
        at liquibase.Liquibase.update(Liquibase.java:251)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1239)
        at liquibase.integration.commandline.Main.run(Main.java:191)
        at liquibase.integration.commandline.Main.main(Main.java:129)


For more information, please use the --logLevel flag

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':updateSQL'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/bin/java'' finished with non-zero exit value 255

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

1 个答案:

答案 0 :(得分:1)

参数作者包含一个等于,但必须为冒号。这很难发现。:)很高兴我能帮上忙。

changeSet(id: '1.0-test-changeset', author:'aoife') {