The MigrateDB Gradle plugin exists to scan your class path during build time. To execute MigrateDB commands during the build, just use Gradle’s scripting capabilities. After all, MigrateDB is just another library.
The MigrateDB Gradle plugin supports Gradle 5 or later running on Java 11 or later.
Add the plugin to your plugins section:
plugins {
id 'de.unentscheidbar.migratedb' version ''
}
Gradle will auto-download the plugin from Gradle’s official plugin repository.
migratedb.gradle.MigrateDbScanThe migratedbScan task will auto-trigger if your build includes the classes task, which should be the case for any
kind of project that targets the JVM or generates a JAR file.
By default, the migratedbScan task will:
db/migrationThis can be changed via the migratedb config object:
migratedb {
scan.includes = ['my/cool/migrations/package']
scan.scope = configurations.runtimeClasspath + sourceSets.main.output
scan.followSymlinks = true
scan.failBuildOnUnprocessablePath = false
}
plugins {
id 'de.unentscheidbar.migratedb'
id 'java-library'
}
group 'com.foo'
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
dependencies {
implementation 'com.foo:db-migrations:1.0'
}
migratedb {
scan.includes = ['db/migration', 'com/foo']
scan.scope = configurations.runtimeClasspath + sourceSets.main.output
}