File tree Expand file tree Collapse file tree
plugin/src/main/kotlin/com/github/gmazzo/buildconfig/internal/bindings Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import org.gradle.api.plugins.ExtensionAware
1313import org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME
1414import org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME
1515import org.gradle.kotlin.dsl.getByName
16+ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
1617import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.Companion.COMMON_MAIN_SOURCE_SET_NAME
1718import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet.Companion.COMMON_TEST_SOURCE_SET_NAME
1819import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget.Companion.METADATA_TARGET_NAME
@@ -96,7 +97,16 @@ internal object KotlinBinder {
9697
9798 target.compilations.all { compilation ->
9899 val ss = compilation.defaultSourceSet
100+
99101 val targetSpec = extension.sourceSets.getByName(nameOf(ss.name))
102+
103+ // adds a default `dependsOn` to either `main` or `test` source set (in case `applyDefaultHierarchyTemplate` was not used)
104+ when (compilation.name) {
105+ KotlinCompilation .MAIN_COMPILATION_NAME -> MAIN_SOURCE_SET_NAME
106+ KotlinCompilation .TEST_COMPILATION_NAME -> TEST_SOURCE_SET_NAME
107+ else -> null
108+ }?.let { targetSpec.dependsOn(extension.sourceSets.getByName(it)) }
109+
100110 val targetDependsOn = targetSpec.allDependsOn.filter { ! it.isSuperseded }
101111
102112 val spec = (sequenceOf(targetSpec) + targetDependsOn)
You can’t perform that action at this time.
0 commit comments