Skip to content

Commit

Permalink
Update to Gradle 7.4
Browse files Browse the repository at this point in the history
Remove clean checks from Gradle 7.4.

Fixes project isolation (#180)
  • Loading branch information
runningcode committed Feb 14, 2022
1 parent 87f378c commit b45478f
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configure<DoctorExtension> {
downloadSpeedWarningThreshold.set(2.0f)
daggerThreshold.set(100)
javaHome {
ensureJavaHomeMatches.set(!providers.environmentVariable("CI").forUseAtConfigurationTime().isPresent)
ensureJavaHomeMatches.set(!providers.environmentVariable("CI").isPresent)
}
}

Expand All @@ -25,7 +25,7 @@ tasks.withType(Test::class.java).configureEach {
}

tasks.wrapper {
gradleVersion = "7.3.3"
gradleVersion = "7.4"
}

buildScan {
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions doctor-plugin/src/main/java/com/osacky/doctor/DoctorPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ class DoctorPlugin : Plugin<Project> {
}

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,9 +24,9 @@ class PluginIntegrationTest constructor(private val version: String) {
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun getParams(): List<String> {
// 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")
}
}

Expand Down Expand Up @@ -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)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b45478f

Please sign in to comment.