Skip to content

Use excludedSources in AndroidPluginIntegration #2503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hensonm-amzn
Copy link

We're seeing an issue in our internal use with KSP that's leading to a circular dependency. Similar to the integration test I've written to go with this change, we have a task that generates code but relies on the output of the KSP task before it runs. We do not need KSP to perform and work on the code generated from our task, so we used the excludedSources API.

The issue is that in the AndroidPluginIntegration class, Android Sources are being added to the source and dependencies of the KSP task without filtering against the excludedSources set. This means that a task added to the Android Sources via an API like SourceDirectories.addGeneratedSourceDirectory() cannot currently be excluded from KSP.

This PR adds logic to that filter in AndroidPluginIntegration that has it respect sources added to excludedSources, allowing us to break the circular dependency.


excludedSources prevents KSP tasks from taking dependencies on any task that is added to the list in an effort to prevent circular dependencies. However, if an output is added via Android Gradle Plugin's APIs, KSP can still end up with a dependency on the task that generates the output, potentially leading to a circular dependency.

This change modifies the filter logic for adding outputs of Android projects to respect outputs added to excludedSources, which can be used to break the circular dependency at the cost of KSP ignoring the added source.

excludedSources prevents KSP tasks from taking dependencies on any
task that is added to the list in an effort to prevent circular
dependencies. However, if an output is added via Android Gradle
Plugin's APIs, KSP can still end up with a dependency on the
task that generates the output, potentially leading to a circular
dependency.

This change modifies the filter logic for adding outputs of Android
projects to respect outputs added to `excludedSources`, which can
be used to break the circular dependency at the cost of KSP ignoring
the added source.
@hensonm-amzn hensonm-amzn changed the title Use excludedSources in Android KAPT Workaround Use excludedSources in Android Integration Code Jun 23, 2025
@hensonm-amzn hensonm-amzn changed the title Use excludedSources in Android Integration Code Use excludedSources in AndroidPluginIntegration Jun 23, 2025
@hensonm-amzn
Copy link
Author

Hi folks, is there more process to getting this reviewed and/or incorporated? If so, please let me know and I'll get those balls rolling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant