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.
This commit is contained in:
Ilya Gorbunov
2018-04-25 23:45:39 +03:00
parent 8e1b0c5ab7
commit a704a1b6d0
+4 -7
View File
@@ -11,14 +11,11 @@ inline fun Project.sourceSets(crossinline body: SourceSetsBuilder.() -> Unit) =
class SourceSetsBuilder(val project: Project) { 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 val sourceSetName = this
project.configure<JavaPluginConvention> return project.the<JavaPluginConvention>().sourceSets.maybeCreate(sourceSetName).apply {
{ none()
sourceSets.matching { it.name == sourceSetName }.forEach { body()
none()
it.body()
}
} }
} }
} }