From 3b741d3a5d8db9a54fe58ad368222aeb849b1f2f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 19 Nov 2015 02:11:08 -0800 Subject: [PATCH] Preliminary support for product flavors and build types. --- .../kotlin/com/beust/kobalt/api/Project.kt | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/api/Project.kt b/src/main/kotlin/com/beust/kobalt/api/Project.kt index 7630d815..a8998422 100644 --- a/src/main/kotlin/com/beust/kobalt/api/Project.kt +++ b/src/main/kotlin/com/beust/kobalt/api/Project.kt @@ -94,6 +94,20 @@ open public class Project( /** Used to disambiguate various name properties */ @Directive val projectName: String get() = name + + private val productFlavors = hashMapOf() + + fun addProductFlavor(name: String, pf: ProductFlavorConfig) { + println("Adding ProductFlavor $name") + productFlavors.put(name, pf) + } + + private val buildTypes = hashMapOf() + + fun addBuildType(name: String, bt: BuildTypeConfig) { + println("Adding BuildType $name") + buildTypes.put(name, bt) + } } public class Sources(val project: Project, val sources: HashSet) { @@ -132,4 +146,23 @@ public class License(val name: String, val url: String) { return result } -} \ No newline at end of file +} + +class ProductFlavorConfig { + var description: String = "" +} + +@Directive +fun Project.productFlavor(name: String, init: ProductFlavorConfig.() -> Unit) = ProductFlavorConfig().apply { + init() + addProductFlavor(name, this) + } + +class BuildTypeConfig { +} + +@Directive +fun Project.buildType(name: String, init: BuildTypeConfig.() -> Unit) = BuildTypeConfig().apply { + init() + addBuildType(name, this) + }