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:
@@ -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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user