bsideup
05/21/2016, 5:56 AMimport kotlin.reflect.KProperty
object Configurations {}
fun dependencies(body: Configurations.() -> Unit) {
Configurations.body()
}
class Configuration(val transitive : Boolean = true) {
operator fun getValue(target: Configurations, property: KProperty<*>): Configuration {
return this
}
operator fun invoke(spec: String, body: Configuration.() -> Unit = {}) : Unit = TODO()
operator fun invoke(group: String, name: String, version: String, classifier: String? = null, body: Configuration.() -> Unit = {}) : Unit = TODO()
fun exclude(group: String? = null, name: String? = null): Unit = TODO()
infix fun extendsFrom(conf: Configuration) : Configuration = this
}
val Configurations.compile by Configuration()
val Configurations.testCompile by Configuration(transitive = false)
/////////////////////////
// Then in the DSL
// //////////////////////
val Configurations.provided by Configuration() extendsFrom Configurations.compile
dependencies {
compile("com.foo:bar:1.2.3") {
exclude(group = "com.bad", name = "dependency")
exclude(name = "junit")
}
provided(group = "javax.servlet", name = "servlet-api", version = "+")
testCompile(group = "com.foo", name = "bar", version = "1.2.3", classifier = "tests")
}