用于gradle的Liquibase插件

时间:2012-09-26 17:02:00

标签: java gradle liquibase

我找到了用于gradle的liquibase插件,很多人推荐我来自 tlberglund gradle-liquibase-plugin。我使用gradle 1.2版 我创建了具有下一个结构的build.gradle:

apply plugin: 'java'
apply plugin: 'liquibase'

repositories {
    mavenCentral()
}

dependencies {
    compile('org.hsqldb:hsqldb:2.2.8')
    compile('org.hsqldb:sqltool:2.2.8')
    compile('com.h2database:h2:1.3.167')
    compile('org.liquibase:liquibase-core:2.0.1')
    compile('com.augusttechgroup:groovy-liquibase-dsl:0.7.3')
    compile('postgresql:postgresql:9.1-901.jdbc4')
}

buildscript {
    dependencies {
        classpath 'com.augusttechgroup:gradle-liquibase-plugin:0.6.1'
    }
}

databases {
    postgre {
        url = "${postgreBaseUrl}" + "${postgreDB}"
        username = "${postgreUserName}"
        password = "${postgreUserPassword}"
    }
}

changelogs {
    main {
        file = file('src/main/liquibase/mainChanges.groovy')
    }
}

task dbInit << {
    databases.postgre.url = "${postgreBaseUrl}"
    databases.postgre.username = "${postgreRootUserName}"
    databases.postgre.password = "${postgreRootUserPassword}"
    changelogs.main.file = file('src/main/liquibase/tablespaceChanges.groovy')
}

当我尝试运行“gradle build”任务时,我收到了短信

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':classpath'.
> Could not find group:com.augusttechgroup, module:gradle-liquibase-plugin, vers
ion:0.6.1.
  Required by:
      :demo:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to
get more log output.

BUILD FAILED

我从中央maven存储库获取了依赖 maven repository

如果我将依赖标记为“编译”,那么就可以了。

dependencies {
    compile 'com.augusttechgroup:gradle-liquibase-plugin:0.6.1' 
}

我检查了我的本地存储库,发现有gradle-liquibase-plugin-0.6.1.jar

我不明白什么是错的。我按照github上原始文档中的描述尝试了

https://github.com/tlberglund/gradle-liquibase-plugin/blob/master/plugin.gradle

但得到了相同的结果。也许有人用过这个插件?

我真的需要帮助,抱歉我的英语不好)

2 个答案:

答案 0 :(得分:1)

问题与Liquibase插件无关。您只需要在buildscript {}部分声明一个存储库。 buildscript {}与脚本的其余部分完全分开。您几乎可以将其视为一个单独的文件。

答案 1 :(得分:0)

查看github上的源代码(请参阅build.gradle文件),看起来构建版本发布在oss.sonatype.org上。尝试使用添加“https://oss.sonatype.org/content/repositories/releases/”作为maven存储库

所以,你的build.gradle可能如下所示:

buildscript {
    repositories {
        maven {
            url uri('https://oss.sonatype.org/content/repositories/releases/')
        }
        mavenCentral()
    }
    dependencies {
        classpath group:'net.saliman', name: 'gradle-liquibase-plugin', version: '1.0.0'
    }
}
apply plugin: 'liquibase'

buildscript { repositories { maven { url uri('https://oss.sonatype.org/content/repositories/releases/') } mavenCentral() } dependencies { classpath group:'net.saliman', name: 'gradle-liquibase-plugin', version: '1.0.0' } } apply plugin: 'liquibase'