From a704a1b6d0d076074e92cf14b3e810951430877a Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 25 Apr 2018 23:45:39 +0300 Subject: [PATCH] Allow to create new sourcesets with our helper New sourceSet is created if it doesn't exist, instead of being silently ignored. Fix receiver of `none()`: it was applied on sourceSetName rather than on the sourceSet, therefore it was a no-operation. --- buildSrc/src/main/kotlin/sourceSets.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/kotlin/sourceSets.kt b/buildSrc/src/main/kotlin/sourceSets.kt index 1df461d9bb6..8468f60961f 100644 --- a/buildSrc/src/main/kotlin/sourceSets.kt +++ b/buildSrc/src/main/kotlin/sourceSets.kt @@ -11,14 +11,11 @@ inline fun Project.sourceSets(crossinline body: SourceSetsBuilder.() -> Unit) = class SourceSetsBuilder(val project: Project) { - inline operator fun String.invoke(crossinline body: SourceSet.() -> Unit) { + inline operator fun String.invoke(crossinline body: SourceSet.() -> Unit): SourceSet { val sourceSetName = this - project.configure - { - sourceSets.matching { it.name == sourceSetName }.forEach { - none() - it.body() - } + return project.the().sourceSets.maybeCreate(sourceSetName).apply { + none() + body() } } }