13

I am in process of migrating our Groovy based scripts to Kotlin. I have been able to get most of done except not sure how to add a dependency for a particular flavour. This is how looks like in Kotlin DSL so far but not sure why the freeImplementation("bar:2.2.8")

 productFlavors {
    create("free") {
         ...
         ...
    }
    create("paid") {
        ...
        ...
    }
}

dependencies {

    implementation("foo:1.2.0")

    // This is not working when migrated to Kotlin DSL
    freeImplementation("bar:2.2.8")

    //Below was the code in Groovy which was working fine earlier 
    //freeImplementation "bar:2.2.8"

}
Bulu
  • 1,351
  • 3
  • 16
  • 37

1 Answers1

17

Below is the solution for it.

 val freeImplementation by configurations
    dependencies {
        freeImplementation("bar:2.2.8")
    }

Alternatively, a string literal can be used to denote a dynamic configuration:

dependencies {
    "freeImplementation"("bar:2.2.8")
}
Bulu
  • 1,351
  • 3
  • 16
  • 37