Skip to content
Merged
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 @@ -89,9 +89,11 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
ignoredClasses.set(extension.stabilityValidation.ignoredClasses)
}

// Make check task depend on stabilityCheck if enabled
target.tasks.named("check") {
dependsOn(stabilityCheckTask)
// Make check task depend on stabilityCheck if enabled (only if check task exists)
target.plugins.withId("base") {
target.tasks.named("check") {
dependsOn(stabilityCheckTask)
}
}

// Configure after project evaluation
Expand Down Expand Up @@ -211,28 +213,54 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {

/**
* Configure task dependencies for stability dump and check tasks.
* Uses lazy configuration to avoid eager task resolution and Gradle 9.x compatibility issues.
*/
private fun configureTaskDependencies(
project: Project,
extension: StabilityAnalyzerExtension,
stabilityDumpTask: org.gradle.api.tasks.TaskProvider<StabilityDumpTask>,
stabilityCheckTask: org.gradle.api.tasks.TaskProvider<StabilityCheckTask>,
) {
val includeTests = extension.stabilityValidation.includeTests.get()

project.tasks.matching { task ->
val isKotlinCompile = task.name.startsWith("compile") && task.name.contains("Kotlin")
val isTestTask = task.name.lowercase().let {
it.contains("test") || it.contains("androidtest") || it.contains("unittest")
}
// Get the includeTests provider for lazy evaluation
val includeTestsProvider = extension.stabilityValidation.includeTests

// Configure dependencies lazily using TaskProvider
stabilityDumpTask.configure {
// Use provider to lazily collect Kotlin compile task names
dependsOn(
project.provider {
val includeTests = includeTestsProvider.get()
project.tasks.matching { task ->
val isKotlinCompile = task.name.startsWith("compile") && task.name.contains("Kotlin")
val isTestTask = task.name.lowercase().let {
it.contains("test") || it.contains("androidtest") || it.contains("unittest")
}
// Include task if it's a Kotlin compile task and either:
// 1. includeTests is true, OR
// 2. it's not a test task
isKotlinCompile && (includeTests || !isTestTask)
}
},
)
}

// Include task if it's a Kotlin compile task and either:
// 1. includeTests is true, OR
// 2. it's not a test task
isKotlinCompile && (includeTests || !isTestTask)
}.all {
stabilityDumpTask.get().dependsOn(this)
stabilityCheckTask.get().dependsOn(this)
stabilityCheckTask.configure {
// Use provider to lazily collect Kotlin compile task names
dependsOn(
project.provider {
val includeTests = includeTestsProvider.get()
project.tasks.matching { task ->
val isKotlinCompile = task.name.startsWith("compile") && task.name.contains("Kotlin")
val isTestTask = task.name.lowercase().let {
it.contains("test") || it.contains("androidtest") || it.contains("unittest")
}
// Include task if it's a Kotlin compile task and either:
// 1. includeTests is true, OR
// 2. it's not a test task
isKotlinCompile && (includeTests || !isTestTask)
}
},
)
}
}

Expand Down