Skip to content

Commit 732cc13

Browse files
committed
add test for gradle 8 compatibility,
remove deprecated gradle 8 api's
1 parent 228a44b commit 732cc13

File tree

4 files changed

+171
-60
lines changed

4 files changed

+171
-60
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package org.unbrokendome.gradle.plugins.testsets
2+
3+
import assertk.assertThat
4+
import assertk.assertions.isIn
5+
import assertk.assertions.isNotNull
6+
import assertk.assertions.prop
7+
import org.gradle.testkit.runner.BuildTask
8+
import org.gradle.testkit.runner.GradleRunner
9+
import org.gradle.testkit.runner.TaskOutcome
10+
import org.junit.jupiter.api.BeforeEach
11+
import org.junit.jupiter.api.DisplayName
12+
import org.junit.jupiter.api.Nested
13+
import org.junit.jupiter.params.ParameterizedTest
14+
import org.junit.jupiter.params.provider.ValueSource
15+
16+
17+
class Gradle8CompatibilityTest : AbstractGradleIntegrationTest() {
18+
19+
abstract inner class AbstractVersionsCompatibilityTest {
20+
21+
@ValueSource(strings = [
22+
"7.5.1", "7.6-rc-3"
23+
])
24+
@ParameterizedTest(name = "Gradle {0}")
25+
@DisplayName("Should work in Gradle version")
26+
fun shouldWorkInGradleVersion(gradleVersion: String) {
27+
val result = GradleRunner.create()
28+
.withProjectDir(projectDir)
29+
.withGradleVersion(gradleVersion)
30+
.withPluginClasspath()
31+
.withArguments("integrationTest", "--info", "--stacktrace", "--warning-mode=fail")
32+
.forwardOutput()
33+
.build()
34+
35+
assertThat(result, "result")
36+
.prop("for task integrationTest") { it.task(":integrationTest") }
37+
.isNotNull()
38+
.prop("outcome", BuildTask::getOutcome)
39+
.isIn(TaskOutcome.NO_SOURCE, TaskOutcome.UP_TO_DATE)
40+
}
41+
}
42+
43+
@Nested
44+
inner class GroovySinple : AbstractVersionsCompatibilityTest() {
45+
46+
@BeforeEach
47+
fun setup() {
48+
directory(projectDir) {
49+
file("build.gradle", """
50+
plugins {
51+
id('org.unbroken-dome.test-sets')
52+
}
53+
54+
testSets { integrationTest }
55+
""")
56+
}
57+
}
58+
}
59+
60+
@Nested
61+
inner class KotlinSimple : AbstractVersionsCompatibilityTest() {
62+
63+
@BeforeEach
64+
fun setup() {
65+
directory(projectDir) {
66+
file("build.gradle.kts", """
67+
plugins {
68+
id("org.unbroken-dome.test-sets")
69+
}
70+
71+
testSets { create("integrationTest") }
72+
""")
73+
}
74+
}
75+
}
76+
77+
@Nested
78+
inner class GroovyExtendsOtherTestSet : AbstractVersionsCompatibilityTest() {
79+
80+
@BeforeEach
81+
fun setup() {
82+
directory(projectDir) {
83+
file("build.gradle", """
84+
plugins {
85+
id('org.unbroken-dome.test-sets')
86+
}
87+
88+
testSets {
89+
extended
90+
91+
integrationTest {
92+
extendsFrom extended
93+
}
94+
}
95+
""")
96+
}
97+
}
98+
}
99+
100+
@Nested
101+
inner class KotlinExtendsOtherTestSet : AbstractVersionsCompatibilityTest() {
102+
103+
@BeforeEach
104+
fun setup() {
105+
directory(projectDir) {
106+
file("build.gradle.kts", """
107+
plugins {
108+
id("org.unbroken-dome.test-sets")
109+
}
110+
111+
testSets {
112+
create("extended")
113+
114+
create("integrationTest") {
115+
extendsFrom("extended")
116+
}
117+
}
118+
""")
119+
}
120+
}
121+
}
122+
123+
@Nested
124+
inner class GroovyLibraries : AbstractVersionsCompatibilityTest() {
125+
126+
@BeforeEach
127+
fun setup() {
128+
directory(projectDir) {
129+
file("build.gradle", """
130+
plugins {
131+
id('org.unbroken-dome.test-sets')
132+
}
133+
134+
testSets {
135+
libraries { testCommon }
136+
137+
integrationTest {
138+
imports 'testCommon'
139+
}
140+
}
141+
""")
142+
}
143+
}
144+
}
145+
146+
@Nested
147+
inner class KotlinLibraries : AbstractVersionsCompatibilityTest() {
148+
149+
@BeforeEach
150+
fun setup() {
151+
directory(projectDir) {
152+
file("build.gradle.kts", """
153+
plugins {
154+
id("org.unbroken-dome.test-sets")
155+
}
156+
157+
testSets {
158+
val testCommon by libraries.creating
159+
160+
create("integrationTest") {
161+
imports(testCommon)
162+
}
163+
}
164+
""")
165+
}
166+
}
167+
}
168+
}

src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/GradleVersionsCompatibilityTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GradleVersionsCompatibilityTest : AbstractGradleIntegrationTest() {
1919
abstract inner class AbstractVersionsCompatibilityTest {
2020

2121
@ValueSource(strings = [
22-
"5.1.1", "5.6.4", "6.0.1", "6.8.3", "7.0"
22+
"5.1.1", "5.6.4", "6.0.1", "6.8.3", "7.0", "7.5.1"
2323
])
2424
@ParameterizedTest(name = "Gradle {0}")
2525
@DisplayName("Should work in Gradle version")

src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetContainer.kt

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.unbrokendome.gradle.plugins.testsets.dsl
22

3-
import groovy.lang.Closure
4-
import groovy.lang.DelegatesTo
3+
import javax.inject.Inject
4+
import kotlin.reflect.KClass
55
import org.gradle.api.Action
66
import org.gradle.api.NamedDomainObjectContainer
77
import org.gradle.api.PolymorphicDomainObjectContainer
@@ -13,9 +13,6 @@ import org.gradle.internal.reflect.Instantiator
1313
import org.gradle.model.internal.core.NamedEntityInstantiator
1414
import org.unbrokendome.gradle.plugins.testsets.util.get
1515
import org.unbrokendome.gradle.plugins.testsets.util.sourceSets
16-
import org.unbrokendome.gradle.plugins.testsets.util.toAction
17-
import javax.inject.Inject
18-
import kotlin.reflect.KClass
1916

2017

2118
/**
@@ -46,27 +43,6 @@ interface TestSetContainer : PolymorphicDomainObjectContainer<TestSetBase> {
4643
fun createTestSet(name: String, configureAction: Action<TestSet>): TestSet =
4744
create(name, TestSet::class.java, configureAction)
4845

49-
50-
/**
51-
* Creates a new test set with the specified name, adds it to the container, and configures it
52-
* with the specified closure.
53-
*
54-
* This variant is intended for Groovy DSL support, with an annotated closure parameter for better
55-
* IDE support.
56-
*
57-
* @param name the name of the test set
58-
* @param configureClosure a closure for configuring the test set
59-
* @return the new [TestSet]
60-
*/
61-
@JvmDefault
62-
override fun create(
63-
name: String,
64-
@DelegatesTo(TestSet::class, strategy = Closure.DELEGATE_FIRST)
65-
configureClosure: Closure<Any>
66-
): TestSet =
67-
create(name, TestSet::class.java, configureClosure.toAction())
68-
69-
7046
/**
7147
* Creates a new test library with the specified name, and adds it to the container.
7248
*
@@ -91,26 +67,6 @@ interface TestSetContainer : PolymorphicDomainObjectContainer<TestSetBase> {
9167
create(name, TestLibrary::class.java, configureAction)
9268

9369

94-
/**
95-
* Creates a new test library with the specified name, adds it to the container, and configures it with
96-
* the specified closure.
97-
*
98-
* This variant is intended for Groovy DSL support, with an annotated closure parameter for better
99-
* IDE support.
100-
*
101-
* @param name the name of the test library
102-
* @param configureClosure an closure for configuring the test library
103-
* @return the new [TestLibrary]
104-
*/
105-
@JvmDefault
106-
fun createLibrary(
107-
name: String,
108-
@DelegatesTo(TestLibrary::class, strategy = Closure.DELEGATE_FIRST)
109-
configureClosure: Closure<*>
110-
): TestLibrary =
111-
createLibrary(name, configureClosure.toAction())
112-
113-
11470
/**
11571
* A [NamedDomainObjectContainer] that wraps this container but presents only the test libraries.
11672
*/
@@ -188,10 +144,6 @@ private open class DefaultTestSetContainer
188144
create(name, TestSet::class.java)
189145

190146

191-
override fun create(name: String, configureClosure: Closure<Any>): TestSet =
192-
create(name, TestSet::class.java, configureClosure.toAction())
193-
194-
195147
private val entityInstantiator = object : NamedEntityInstantiator<TestSetBase> {
196148
@Suppress("UNCHECKED_CAST")
197149
override fun <S : TestSetBase> create(name: String, type: Class<S>): S {

src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/util/ClosureExtensions.kt

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)