Bulu
Bulu

Reputation: 1441

Adds an implementation dependency only to the "free" product flavor in Kotlin DSL

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"

}

Upvotes: 14

Views: 2279

Answers (1)

Bulu
Bulu

Reputation: 1441

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")
}

Upvotes: 22

Related Questions