Skip to content

Project Isolation: Project cannot access task dependencies directly #1943

@consp1racy

Description

@consp1racy

buildDependencies.getDependencies(null) isn't compatible with Project Isolation.

⌄⨉Project :app cannot access task dependencies directly
⌄plugin 'org.jetbrains.kotlin.android'
›Exception at com.google.devtools.ksp.gradle.KspGradleSubplugin.applyToCompilation$configureAsAbstractKotlinCompileTool(KspSubplugin.kt:322)
›Exception at com.google.devtools.ksp.gradle.KspSubpluginKt.nonSelfDeps(KspSubplugin.kt:864)

if (kspExtension.allowSourcesFromOtherPlugins) {
fun setSource(source: FileCollection) {
// kspTask.setSource(source) would create circular dependency.
// Therefore we need to manually extract input deps, filter them, and tell kspTask.
kspTask.setSource(project.provider { source.files })
kspTask.dependsOn(project.provider { source.nonSelfDeps(kspTaskName) })
}
setSource(
kotlinCompileTask.sources.filter {
!kotlinOutputDir.isParentOf(it) && !javaOutputDir.isParentOf(it)
}
)
if (kotlinCompileTask is KotlinCompile) {
setSource(
kotlinCompileTask.javaSources.filter {
!kotlinOutputDir.isParentOf(it) && !javaOutputDir.isParentOf(it)
}
)
}
} else {
val filteredTasks =
kspExtension.excludedSources.buildDependencies.getDependencies(null).map { it.name }
kotlinCompilation.allKotlinSourceSetsObservable.forAll { sourceSet ->
kspTask.setSource(
sourceSet.kotlin.srcDirs.filter {
!kotlinOutputDir.isParentOf(it) && !javaOutputDir.isParentOf(it) &&
it !in kspExtension.excludedSources
}
)
kspTask.dependsOn(sourceSet.kotlin.nonSelfDeps(kspTaskName).filter { it.name !in filteredTasks })
}
}

internal fun FileCollection.nonSelfDeps(selfTaskName: String): List<Task> =
buildDependencies.getDependencies(null).filterNot {
it.name == selfTaskName
}

https://github.com/gradle/gradle/blob/master/platforms/core-configuration/configuration-cache/src/main/kotlin/org/gradle/configurationcache/ReportingTaskDependencyUsageTracker.kt

I'm looking for a PI-compatible alternative API. Or waiting for the Gradle team to make the exiting API compatible ^^


Reading properties from parent projects can be prevented by assigning same-named extras on every project using KSP. That's another problem, that can already be worked around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions