简体   繁体   English

飞路和Gradle Kotlin DSL

[英]Flyway and gradle kotlin dsl

I'm migrating from Gradle to Gradle Kotlin DSL, and I have a question. 我正在从Gradle迁移到Gradle Kotlin DSL,我有一个问题。 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? 您如何看待Kotlin DSL?

The code in the block is almost exactly the same in Kotlin as in Groovy, with two exceptions for what you have above: 该块中的代码在Kotlin中与Groovy几乎完全相同,但上面有两个例外:

  • Use double-quotes instead of single-quotes for the strings. 字符串使用双引号而不是单引号。
  • Use arrayOf instead of [...] for the array for the locations property. arrayOf而不是[...]用于locations属性的数组。

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: 请记住,要使构建文件了解flyway功能(并让IDE flyway告知您块中可用的选项,等等),您需要使用Gradle Plugins DSL应用Flyway插件,如下所示: build.gradle.kts文件的顶部:

plugins {
    id("org.flywaydb.flyway") version "5.2.4"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM