1

我正在将一个 Maven 项目转换为 gradle。在 Maven 中,他们使用了 c5-db-migration 插件。我们在 gradle 中有类似的东西吗?

4

3 回答 3

2

You can use the Flyway Ant Tasks. Also there is a gradle plugin in work (beta status).

Example:

configurations {
    flyway
}

task flywayMigrate(dependsOn: "build") << {
    ext.flyway_classpath = files(sourceSets.main.output.resourcesDir) + files(configurations.flyway)
    ant.taskdef(name: 'flywayMigrate', classname: 'com.googlecode.flyway.ant.MigrateTask', classpath: ext.flyway_classpath.asPath)
    ant.flywayMigrate(driver: 'oracle.jdbc.driver.OracleDriver', url: 'myurl', user: 'myusername', password: 'mypassword',
            encoding: 'Cp1252', baseDir: 'sql')
}

dependencies {
    compile "com.googlecode.flyway:flyway-core:1.7"
    compile "com.oracle:ojdbc6:11.2.0.1.0"
    flyway "com.oracle:ojdbc6:11.2.0.1.0"
    flyway "com.googlecode.flyway:flyway-ant:1.7"
}
于 2012-10-10T08:52:08.870 回答
1

我写了一篇你可以找到的@(https://github.com/katta/gradle-flyway-plugin)

最简单的用法是这样的

buildscript {
  repositories {
    mavenCentral()
    maven {
        url uri('http://katta.github.com/repository')
    }
  }
  dependencies {
    classpath 'org.katta.gradle.api.plugins:flyway:1.3'
    classpath 'postgresql:postgresql:9.1-901.jdbc4'
  }
}

apply plugin: 'flyway'

## replace properties with the values with your database settings
flyway {
    driver='org.postgresql.Driver'
    url='jdbc:postgresql://127.0.0.1/flyway' 
    user='postgres'
    password='s#cRet'
}

这里的文档详细解释了如何使用它。如果您在使用它时遇到任何问题,请告诉我。

于 2012-10-26T15:31:08.643 回答
0

There is a liquibase plugin for gradle available written by tim berglund. The plugin is available at github: https://github.com/tlberglund/gradle-liquibase-plugin

Maybe that helps you.

cheers, René

于 2012-10-10T08:14:42.957 回答