8000 Marking processorOptions as internal (KspAATask) by cdsap · Pull Request #2474 · google/ksp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Marking processorOptions as internal (KspAATask) #2474

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 2 commits into
base: main
Choose a base branch
from

Conversation

cdsap
Copy link
Contributor
@cdsap cdsap commented May 28, 2025

This PR addresses google/ksp#2467.

The issue originates from the MapProperty processorOptions in KspGradleConfig when using KspAATask. This map is populated with command-line argument values, but it is not aware of Gradle’s path sensitivity requirements, which leads to incorrect behavior, causing remote cache misses.

As a workaround, this PR marks processorOptions as @Internal and instead relies on commandLineArgumentProviders in KspAATask to correctly track these inputs. To support this, similar to what is done in KspJvmTask, we inject the KSP extension's command-line argument providers into the task command line argument.

Since processorOptions is also populated from kspExtension.apOptions, we introduce a new MapProperty named apOptions to explicitly track these inputs.

Let me know your thoughts!

Tests

Original issue when using ksp2 with room and comparing two builds with different location:
Screenshot 2025-05-27 at 4 59 52 PM
https://ge.solutions-team.gradle.com/c/7miiiuiclpapk/bssjjcajc36gu/task-inputs

Same scenario, but with this PR approach:
Screenshot 2025-05-27 at 5 00 07 PM

https://ge.solutions-team.gradle.com/c/nsld3bkfkwrmg/oqhb3co46yqto/task-inputs?cacheability=cacheable,overlapping-outputs,validation-failure

Now, forcing a change in the room gradle plugin configuration to use a different value to demonstrate that the inputs are tracked:

Screenshot 2025-05-27 at 5 08 10 PM

https://ge.solutions-team.gradle.com/c/d5yqiarcqmvnm/o52lpx2yreajg/task-inputs

And finally, defining a commandLine argument and using it in the ksp extension like:

extensions.configure<KspExtension> {
       arg("room.generateKotlin", "true")
       arg(Provider(project.layout.projectDirectory.dir("schemas2").asFile))
}
...
class Provider(roomOutputDir: File) : CommandLineArgumentProvider {

    @OutputDirectory
    val outputDir = roomOutputDir

    override fun asArguments(): Iterable<String> {
        return listOf(
            "test.schemaLocation=${outputDir.path}",

        )
    }
}
Screenshot 2025-05-27 at 5 05 12 PM

https://ge.solutions-team.gradle.com/c/o52lpx2yreajg/kwryqqhvnrku6/task-inputs

@cdsap cdsap changed the title Marking as internal processorOptions (KspAATask) Marking processorOptions as internal (KspAATask) May 28, 2025
@cdsap
Copy link
Contributor Author
cdsap commented Jul 7, 2025

@ting-yuan If you have a moment, could you please take a look at this PR related to this issue?
We're seeing more Android projects migrating to KSP2 lately, and this cache miss issue is starting to surface.

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
0