Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.UnknownDomainObjectException
import org.gradle.api.logging.Logger
import org.gradle.api.tasks.TaskProvider
import java.io.File

/**
Expand Down Expand Up @@ -232,7 +233,7 @@ abstract class AffectedModuleDetector {
}

/**
* Call this method to configure the given task to execute only if the owner project
* Call this method to configure the given provided task to execute only if the owner project
* is affected by current changes
*
* Can be called during the configuration or execution phase
Expand All @@ -247,6 +248,24 @@ abstract class AffectedModuleDetector {
}
}

/**
* Call this method to configure the given task to execute only if the owner project
* is affected by current changes
*
* Can be called during the configuration or execution phase
*/
@Throws(GradleException::class)
@JvmStatic
fun configureTaskGuard(taskProvider: TaskProvider<out Task>) {
taskProvider.configure { task ->
task.onlyIf {
getOrThrow(
task.project
).shouldInclude(task.project)
}
}
}

/**
* Call this method to determine if the project was affected in this change
*
Expand Down Expand Up @@ -340,7 +359,11 @@ class AffectedModuleDetectorImpl constructor(
injectedGitClient ?: GitClientImpl(
rootProject.projectDir,
logger,
commitShaProvider = CommitShaProvider.fromString(config.compareFrom, config.specifiedBranch, config.specifiedRawCommitSha),
commitShaProvider = CommitShaProvider.fromString(
config.compareFrom,
config.specifiedBranch,
config.specifiedRawCommitSha
),
ignoredFiles = config.ignoredFiles
)
}
Expand Down