Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

}
like image 227
Bulu Avatar asked Aug 22 '18 12:08

Bulu


1 Answers

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")
}
like image 90
Bulu Avatar answered Nov 18 '22 23:11

Bulu