Skip to content

Commit

Permalink
Merge pull request #152 from dropbox/jfein/disable-config-cache
Browse files Browse the repository at this point in the history
Upgrade Gradle Plugin so we can have knowledge of how to disable config cache
  • Loading branch information
joshafeinberg authored Jul 15, 2022
2 parents 4edeb41 + 9c5040e commit 974485f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.testing.Test
import org.gradle.internal.impldep.org.jetbrains.annotations.VisibleForTesting
import org.gradle.util.GradleVersion

/**
* This plugin creates and registers all affected test tasks.
Expand Down Expand Up @@ -95,6 +96,7 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
val task = rootProject.tasks.register(taskType.commandByImpact).get()
task.group = CUSTOM_TASK_GROUP_NAME
task.description = taskType.taskDescription
disableConfigCache(task)

rootProject.subprojects { project ->
pluginIds.forEach { pluginId ->
Expand Down Expand Up @@ -125,6 +127,7 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
)
}

@Suppress("UnstableApiUsage")
@VisibleForTesting
internal fun registerInternalTask(
rootProject: Project,
Expand All @@ -134,6 +137,7 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
val task = rootProject.tasks.register(taskType.commandByImpact).get()
task.group = groupName
task.description = taskType.taskDescription
disableConfigCache(task)

rootProject.subprojects { project ->
project.afterEvaluate { evaluatedProject ->
Expand All @@ -150,6 +154,12 @@ class AffectedModuleDetectorPlugin : Plugin<Project> {
}
}

private fun disableConfigCache(task: Task) {
if (GradleVersion.current() >= GradleVersion.version("7.4")) {
task.notCompatibleWithConfigurationCache("AMD requires knowledge of what has changed in the file system so we can not cache those values (https://github.com/dropbox/AffectedModuleDetector/issues/150)")
}
}

private fun withPlugin(
pluginId: String,
task: Task,
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
2 changes: 1 addition & 1 deletion sample/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip

0 comments on commit 974485f

Please sign in to comment.