diff --git a/build.gradle.kts b/build.gradle.kts index 349e729f..3ab51449 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ configure { downloadSpeedWarningThreshold.set(2.0f) daggerThreshold.set(100) javaHome { - ensureJavaHomeMatches.set(!providers.environmentVariable("CI").forUseAtConfigurationTime().isPresent) + ensureJavaHomeMatches.set(!providers.environmentVariable("CI").isPresent) } } @@ -25,7 +25,7 @@ tasks.withType(Test::class.java).configureEach { } tasks.wrapper { - gradleVersion = "7.3.3" + gradleVersion = "7.4" } buildScan { diff --git a/docs/changelog.md b/docs/changelog.md index f6a0735d..761d0d61 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ ## 0.8.0 * [Skip multiple daemons check on non-Unix machines, not supported yet](https://github.com/runningcode/gradle-doctor/issues/84) * [Detect Kotlin Compiler Daemon failing to connect.](https://github.com/runningcode/gradle-doctor/issues/194) +* [Clean check is disabled in Gradle 7.4+, fixes compatibility with project isolation](https://github.com/runningcode/gradle-doctor/issues/180) ## 0.7.3 * Fix [compatiblity with Java 8.](https://github.com/runningcode/gradle-doctor/issues/171) diff --git a/doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt b/doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt index e572dffa..4550e365 100644 --- a/doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt +++ b/doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt @@ -172,6 +172,10 @@ class DoctorPlugin : Plugin { } private fun ensureNoCleanTaskDependenciesIfNeeded(target: Project, extension: DoctorExtension, pillBoxPrinter: PillBoxPrinter) { + if (GradleVersion.current() >= GradleVersion.version("7.4")) { + // Gradle 7.4 has a fix for 2488 and 10889 + return + } target.allprojects { // We use afterEvaluate in case other plugins configure the Delete task. We want our configuration to happen last. afterEvaluate { diff --git a/doctor-plugin/src/test/java/com/osacky/doctor/PluginIntegrationTest.kt b/doctor-plugin/src/test/java/com/osacky/doctor/PluginIntegrationTest.kt index 445e61be..66afc1af 100644 --- a/doctor-plugin/src/test/java/com/osacky/doctor/PluginIntegrationTest.kt +++ b/doctor-plugin/src/test/java/com/osacky/doctor/PluginIntegrationTest.kt @@ -5,6 +5,8 @@ import com.osacky.doctor.internal.androidHome import org.gradle.testkit.runner.GradleRunner import org.gradle.util.GradleVersion import org.junit.Assume +import org.junit.Assume.assumeFalse +import org.junit.Assume.assumeTrue import org.junit.Ignore import org.junit.Rule import org.junit.Test @@ -22,9 +24,9 @@ class PluginIntegrationTest constructor(private val version: String) { @JvmStatic @Parameterized.Parameters(name = "{0}") fun getParams(): List { - // Keep 5.0 as minimum unsupported version and 5.1 as minimum supported version. + // Keep 6.0 as minimum unsupported version and 6.1 as minimum supported version. // Keep this list to 5 as testing against too many versions causes OOMs. - return listOf("6.0.1", "6.1.1", "6.5.1", "7.0", "7.3.3") + return listOf("6.0.1", "6.1.1", "6.5.1", "7.0", "7.3.3", "7.4") } } @@ -434,6 +436,72 @@ class PluginIntegrationTest constructor(private val version: String) { assertThat(result.output).contains("SUCCESS") } + @Test + fun cleanDependencyFailsBuild() { + assumeSupportedVersion() + assumeTrue(GradleVersion.version(version) < GradleVersion.version("7.4")) + writeBuildGradle( + """ + |plugins { + | id "com.osacky.doctor" + | id 'base' + |} + |doctor { + | disallowMultipleDaemons = false + | javaHome { + | ensureJavaHomeIsSet = false + | ensureJavaHomeMatches = false + | } + | failOnEmptyDirectories = true + | warnWhenNotUsingParallelGC = false + |} + |task foo + |tasks.withType(Delete).configureEach { + | dependsOn foo + |} + """.trimMargin("|") + ) + + val result = createRunner() + .withArguments("clean") + .buildAndFail() + + assertThat(result.output).contains("Adding dependencies to the clean task could cause unexpected build outcomes.") + } + + @Test + fun cleanDependencySucceedsInGradle74Plus() { + assumeSupportedVersion() + assumeTrue(GradleVersion.version(version) >= GradleVersion.version("7.4")) + writeBuildGradle( + """ + |plugins { + | id "com.osacky.doctor" + | id 'base' + |} + |doctor { + | disallowMultipleDaemons = false + | javaHome { + | ensureJavaHomeIsSet = false + | ensureJavaHomeMatches = false + | } + | failOnEmptyDirectories = true + | warnWhenNotUsingParallelGC = false + |} + |task foo + |tasks.withType(Delete).configureEach { + | dependsOn foo + |} + """.trimMargin("|") + ) + + val result = createRunner() + .withArguments("clean") + .build() + + assertThat(result.output).contains("SUCCESS") + } + private fun createRunner(): GradleRunner { return GradleRunner.create() .withProjectDir(testProjectRoot.root) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f..41d9927a 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897..41dfb879 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists