diff --git a/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/Gradle8CompatibilityTest.kt b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/Gradle8CompatibilityTest.kt new file mode 100644 index 0000000..78bf686 --- /dev/null +++ b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/Gradle8CompatibilityTest.kt @@ -0,0 +1,168 @@ +package org.unbrokendome.gradle.plugins.testsets + +import assertk.assertThat +import assertk.assertions.isIn +import assertk.assertions.isNotNull +import assertk.assertions.prop +import org.gradle.testkit.runner.BuildTask +import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Nested +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + + +class Gradle8CompatibilityTest : AbstractGradleIntegrationTest() { + + abstract inner class AbstractVersionsCompatibilityTest { + + @ValueSource(strings = [ + "7.5.1", "7.6-rc-3" + ]) + @ParameterizedTest(name = "Gradle {0}") + @DisplayName("Should work in Gradle version") + fun shouldWorkInGradleVersion(gradleVersion: String) { + val result = GradleRunner.create() + .withProjectDir(projectDir) + .withGradleVersion(gradleVersion) + .withPluginClasspath() + .withArguments("integrationTest", "--info", "--stacktrace", "--warning-mode=fail") + .forwardOutput() + .build() + + assertThat(result, "result") + .prop("for task integrationTest") { it.task(":integrationTest") } + .isNotNull() + .prop("outcome", BuildTask::getOutcome) + .isIn(TaskOutcome.NO_SOURCE, TaskOutcome.UP_TO_DATE) + } + } + + @Nested + inner class GroovySinple : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle", """ + plugins { + id('org.unbroken-dome.test-sets') + } + + testSets { integrationTest } + """) + } + } + } + + @Nested + inner class KotlinSimple : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle.kts", """ + plugins { + id("org.unbroken-dome.test-sets") + } + + testSets { create("integrationTest") } + """) + } + } + } + + @Nested + inner class GroovyExtendsOtherTestSet : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle", """ + plugins { + id('org.unbroken-dome.test-sets') + } + + testSets { + extended + + integrationTest { + extendsFrom extended + } + } + """) + } + } + } + + @Nested + inner class KotlinExtendsOtherTestSet : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle.kts", """ + plugins { + id("org.unbroken-dome.test-sets") + } + + testSets { + create("extended") + + create("integrationTest") { + extendsFrom("extended") + } + } + """) + } + } + } + + @Nested + inner class GroovyLibraries : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle", """ + plugins { + id('org.unbroken-dome.test-sets') + } + + testSets { + libraries { testCommon } + + integrationTest { + imports 'testCommon' + } + } + """) + } + } + } + + @Nested + inner class KotlinLibraries : AbstractVersionsCompatibilityTest() { + + @BeforeEach + fun setup() { + directory(projectDir) { + file("build.gradle.kts", """ + plugins { + id("org.unbroken-dome.test-sets") + } + + testSets { + val testCommon by libraries.creating + + create("integrationTest") { + imports(testCommon) + } + } + """) + } + } + } +} diff --git a/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/GradleVersionsCompatibilityTest.kt b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/GradleVersionsCompatibilityTest.kt index e77009a..c409cf2 100644 --- a/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/GradleVersionsCompatibilityTest.kt +++ b/src/integrationTest/kotlin/org/unbrokendome/gradle/plugins/testsets/GradleVersionsCompatibilityTest.kt @@ -19,7 +19,7 @@ class GradleVersionsCompatibilityTest : AbstractGradleIntegrationTest() { abstract inner class AbstractVersionsCompatibilityTest { @ValueSource(strings = [ - "5.1.1", "5.6.4", "6.0.1", "6.8.3", "7.0" + "5.1.1", "5.6.4", "6.0.1", "6.8.3", "7.0", "7.5.1" ]) @ParameterizedTest(name = "Gradle {0}") @DisplayName("Should work in Gradle version") diff --git a/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetContainer.kt b/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetContainer.kt index e7a9045..e7dec97 100644 --- a/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetContainer.kt +++ b/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/dsl/TestSetContainer.kt @@ -1,7 +1,7 @@ package org.unbrokendome.gradle.plugins.testsets.dsl -import groovy.lang.Closure -import groovy.lang.DelegatesTo +import javax.inject.Inject +import kotlin.reflect.KClass import org.gradle.api.Action import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.PolymorphicDomainObjectContainer @@ -13,9 +13,6 @@ import org.gradle.internal.reflect.Instantiator import org.gradle.model.internal.core.NamedEntityInstantiator import org.unbrokendome.gradle.plugins.testsets.util.get import org.unbrokendome.gradle.plugins.testsets.util.sourceSets -import org.unbrokendome.gradle.plugins.testsets.util.toAction -import javax.inject.Inject -import kotlin.reflect.KClass /** @@ -46,27 +43,6 @@ interface TestSetContainer : PolymorphicDomainObjectContainer { fun createTestSet(name: String, configureAction: Action): TestSet = create(name, TestSet::class.java, configureAction) - - /** - * Creates a new test set with the specified name, adds it to the container, and configures it - * with the specified closure. - * - * This variant is intended for Groovy DSL support, with an annotated closure parameter for better - * IDE support. - * - * @param name the name of the test set - * @param configureClosure a closure for configuring the test set - * @return the new [TestSet] - */ - @JvmDefault - override fun create( - name: String, - @DelegatesTo(TestSet::class, strategy = Closure.DELEGATE_FIRST) - configureClosure: Closure - ): TestSet = - create(name, TestSet::class.java, configureClosure.toAction()) - - /** * Creates a new test library with the specified name, and adds it to the container. * @@ -91,26 +67,6 @@ interface TestSetContainer : PolymorphicDomainObjectContainer { create(name, TestLibrary::class.java, configureAction) - /** - * Creates a new test library with the specified name, adds it to the container, and configures it with - * the specified closure. - * - * This variant is intended for Groovy DSL support, with an annotated closure parameter for better - * IDE support. - * - * @param name the name of the test library - * @param configureClosure an closure for configuring the test library - * @return the new [TestLibrary] - */ - @JvmDefault - fun createLibrary( - name: String, - @DelegatesTo(TestLibrary::class, strategy = Closure.DELEGATE_FIRST) - configureClosure: Closure<*> - ): TestLibrary = - createLibrary(name, configureClosure.toAction()) - - /** * A [NamedDomainObjectContainer] that wraps this container but presents only the test libraries. */ @@ -188,10 +144,6 @@ private open class DefaultTestSetContainer create(name, TestSet::class.java) - override fun create(name: String, configureClosure: Closure): TestSet = - create(name, TestSet::class.java, configureClosure.toAction()) - - private val entityInstantiator = object : NamedEntityInstantiator { @Suppress("UNCHECKED_CAST") override fun create(name: String, type: Class): S { diff --git a/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/util/ClosureExtensions.kt b/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/util/ClosureExtensions.kt deleted file mode 100644 index 96cd260..0000000 --- a/src/main/kotlin/org/unbrokendome/gradle/plugins/testsets/util/ClosureExtensions.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.unbrokendome.gradle.plugins.testsets.util - -import groovy.lang.Closure -import org.gradle.api.Action -import org.gradle.util.ConfigureUtil - - -fun Closure<*>.toAction(): Action = - ConfigureUtil.configureUsing(this)