Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flyway and gradle kotlin dsl

I'm migrating from Gradle to Gradle Kotlin DSL, and I have a question. Have

flyway {
    url = System.getenv ('DB_URL')
    user = System.getenv ('DB_USER')
    password = System.getenv ('DB_PASSWORD')
    baselineOnMigrate = true
    locations = ["filesystem: resources / db / migration"]
}

In Gradle.

How would you look in Kotlin DSL?

like image 325
Rodrigo Batista Avatar asked May 29 '19 15:05

Rodrigo Batista


1 Answers

The code in the block is almost exactly the same in Kotlin as in Groovy, with two exceptions for what you have above:

  • Use double-quotes instead of single-quotes for the strings.
  • Use arrayOf instead of [...] for the array for the locations property.

In other words it would look as follows:

flyway {
    url = System.getenv("DB_URL")
    user = System.getenv("DB_USER")
    password = System.getenv("DB_PASSWORD")
    baselineOnMigrate = true
    locations = arrayOf("filesystem: resources / db / migration")
}

Bear in mind that for the build file to understand the flyway function (and for the IDE to give you intellisense for what options are available in the block, etc.) you need to apply the Flyway plugin using the Gradle Plugins DSL, as follows at the top of your build.gradle.kts file:

plugins {
    id("org.flywaydb.flyway") version "5.2.4"
}
like image 106
Yoni Gibbs Avatar answered Oct 14 '22 00:10

Yoni Gibbs