File tree Expand file tree Collapse file tree
main/kotlin/com/github/gmazzo/buildconfig/internal
test/kotlin/com/github/gmazzo/buildconfig Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ internal abstract class DefaultBuildConfigSourceSet(
6565
6666 if (! isSuperseded) {
6767 isSuperseded = true
68- generateTask.configure {
69- supersededBy(other)
68+ generateTask.configure { t ->
69+ t. supersededBy(other)
7070 }
7171 }
7272
Original file line number Diff line number Diff line change 1+ package com.github.gmazzo.buildconfig
2+
3+ import com.github.gmazzo.buildconfig.internal.BuildConfigSourceSetInternal
4+ import com.github.gmazzo.buildconfig.internal.DefaultBuildConfigSourceSet
5+ import com.github.gmazzo.buildconfig.internal.capitalized
6+ import org.gradle.kotlin.dsl.newInstance
7+ import org.gradle.kotlin.dsl.register
8+ import org.gradle.testfixtures.ProjectBuilder
9+ import org.junit.jupiter.api.Test
10+ import org.junit.jupiter.api.assertDoesNotThrow
11+
12+ class BuildConfigSupersededByTest {
13+ private val project = ProjectBuilder .builder().build()
14+
15+ private fun createSourceSet (name : String ): BuildConfigSourceSetInternal = with (project) {
16+ objects.newInstance<DefaultBuildConfigSourceSet >(name).apply {
17+ generateTask = tasks.register<BuildConfigTask >(" generate${name.capitalized} BuildConfigClasses" ) {
18+ outputDir.set(layout.buildDirectory.dir(" generated/sources/buildConfig/$name " ))
19+ }
20+ }
21+ }
22+
23+ @Test
24+ fun `supersededBy with forClass should not fail when task is realized` () {
25+ val parent = createSourceSet(" test" )
26+ val child = createSourceSet(" testDebug" )
27+
28+ parent.forClass(" MyBuildConfig" )
29+ parent.supersededBy(child)
30+
31+ assertDoesNotThrow { parent.generateTask.get() }
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments