@@ -561,21 +561,63 @@ class IntelliJPluginSpec : IntelliJPluginSpecBase() {
561561 }
562562
563563 @Test
564- fun `throws exception if Gradle is lt 6_8` () {
565- val message = " Gradle IntelliJ Plugin requires Gradle $MINIMAL_SUPPORTED_GRADLE_VERSION and higher"
564+ fun `expect build fails when using unsupported Gradle version` () {
565+ val unsupportedGradleVersions = setOf (
566+ " 6.4" ,
567+ " 6.7.1" ,
568+ )
566569
567- build(" 6.4" , true , " help" ).output.let {
568- assertTrue(it.contains(" FAILURE: Build failed with an exception." ))
570+ unsupportedGradleVersions.forEach { gradleVersion ->
571+ build(gradleVersion, true , " help" ).apply {
572+ assertContains(" Gradle IntelliJ Plugin requires Gradle" , output)
573+ assertContains(" FAILURE: Build failed with an exception" , output)
574+ }
569575 }
576+ }
570577
571- build(" 6.7.1" , true , " help" ).output.let {
572- assertTrue(it.contains(" FAILURE: Build failed with an exception." ))
573- }
578+ /* *
579+ * Note: An older version of `kotlin("jvm")` is because 1.7.+ requires Gradle 7.1.
580+ *
581+ * (specifically `kotlin("jvm")` requires the method [org.gradle.api.plugins.JavaPluginExtension.getSourceSets])
582+ */
583+ @Test
584+ fun `expect successful build using minimal supported Gradle version` () {
574585
575- build(MINIMAL_SUPPORTED_GRADLE_VERSION , false , " help" ).output.let {
576- assertTrue(it.contains(" BUILD SUCCESSFUL" ))
577- assertFalse(it.contains(message))
578- }
586+ buildFile.writeText(" " ) // reset the build file - need to apply an older version of Kotlin plugin
587+ buildFile.groovy(
588+ """
589+ plugins {
590+ id 'org.jetbrains.intellij'
591+ id 'org.jetbrains.kotlin.jvm' version '1.4.0'
592+ }
593+ sourceCompatibility = 11
594+ targetCompatibility = 11
595+ repositories {
596+ mavenCentral()
597+ }
598+ intellij {
599+ version = '$intellijVersion '
600+ downloadSources = false
601+ pluginsRepositories {
602+ maven('$pluginsRepository ')
603+ }
604+ instrumentCode = false
605+ }
606+ buildSearchableOptions {
607+ enabled = false
608+ }
609+
610+ // Define tasks with a minimal set of tasks required to build a source set
611+ sourceSets.all {
612+ task(it.getTaskName('build', 'SourceSet'), dependsOn: it.output)
613+ }
614+ """ .trimIndent()
615+ )
616+
617+ val buildResult = build(MINIMAL_SUPPORTED_GRADLE_VERSION , false , " help" )
618+
619+ assertContains(" BUILD SUCCESSFUL" , buildResult.output)
620+ assertNotContains(" Gradle IntelliJ Plugin requires Gradle" , buildResult.output)
579621 }
580622
581623 @SuppressWarnings(" GrEqualsBetweenInconvertibleTypes" )
0 commit comments