'Flyway in Kotlin Gradle - cannot import FlywayMigrateTask

I need to run two different flyway migrations on two different shcemas, each with their own user account. According to the Flyway documentation I only need to set up one custom task for each connection with FlywayMigrateTask. From official documentation using default (Groovy) gradle:

task migrateDatabase1(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
    url = 'jdbc:h2:mem:mydb1'
    user = 'myUsr1'
    password = 'mySecretPwd1'
}

task migrateDatabase2(type: org.flywaydb.gradle.task.FlywayMigrateTask) {
    url = 'jdbc:h2:mem:mydb2'
    user = 'myUsr2'
    password = 'mySecretPwd2'
}

I try to do this in Kotlin gradle (kts) but my project can't resolve the refrence to FlywayMigrateTask, even though I have it in my External Libraties:

enter image description here

How I register task:

tasks.register(
    "flywayTesting", 
    type = org.flywaydb.gradle.task.FlywayMigrateTask::class.java) {
    // Details hidden
}

I'm able to resolve org.flywaydb.gradle.task package but not the FlywayMigrateTask class in the task folder. What am I doing wrong?

enter image description here

Highligts from my gradle setup:

plugins {
    kotlin("jvm") version "1.6.0"
    id("org.flywaydb.flyway") version "8.5.1"
}

repositories {
    mavenCentral()
}

tasks.withType<Wrapper> {
    gradleVersion = "6.8.2"
    distributionType = Wrapper.DistributionType.BIN
}

dependencies {
    implementation("org.flywaydb:flyway-core:8.5.1")
    implementation("org.flywaydb:flyway-gradle-plugin:8.5.0")
}

kotlin {
    sourceSets["main"].apply {
        kotlin.srcDir("src/main/kotlin")
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source