Skip to content

Instantly share code, notes, and snippets.

@utamori
Created May 15, 2020 03:09
Show Gist options
  • Save utamori/bc9b6bf31a16bbba7597a3d123251a1b to your computer and use it in GitHub Desktop.
Save utamori/bc9b6bf31a16bbba7597a3d123251a1b to your computer and use it in GitHub Desktop.

build.gradle.ktsメモ

Gradle - Plugins

Groovyからの移行

  • 文字列にはシングルクォートの代わりにダブルクォートを使う。
  • 配列には[....]の代わりにarrayOfを使う。

テスト kotest

tasks.withType<Test> {
  useJUnitPlatform()
}

dependencies {
  testImplementation("io.kotest:kotest-runner-junit5-jvm:<version>") // for kotest framework
  testImplementation("io.kotest:kotest-assertions-core-jvm:<version>") // for kotest core jvm assertions
  testImplementation("io.kotest:kotest-property-jvm:<version>") // for kotest property test
}

パッケージング fatJar x ktor

  • shadowプラグインをいれる
  • shadowJarタスクの設定
  • ktorにmainクラスを設定
plugins {
    application
    kotlin("jvm") version "1.3.21"
    id("com.github.johnrengelman.shadow") version "5.2.0"
}

application {
    mainClass.set("io.ktor.server.netty.EngineMain")
}

tasks.shadowJar {
    manifest {
        attributes(mapOf("Main-Class" to application.mainClass.get()))
    }
}

データベース構成管理 flyway

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

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

参考:Flyway and gradle kotlin dsl - Stack Overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment